Hub Of Geekz

  • Home
  • About Me
  • Contact Us
  • Home
  • Languages
    • C++
    • Java
    • Perl
    • Prolog
    • Bootstrap
  • Database
    • SQL
    • PL/SQL
  • Study
    • Java
      • Java Collection
      • Java Concurrency
      • Java Interview Questions
      • Java Networking
    • Number System
  • Kavita
  • Entertainment
    • Hinglish Cafe
    • Videos
    • Jokes
  • Windows Tricks
  • How To

Friday, 27 February 2015

Sub Routines in Perl

 Earthcare Foundation NGO     23:32     Perl     No comments   

In this post i will explain some subroutine in Perl.

1)AUTOLOAD subroutine: 

In perl , if this subroutine is defined in the package, then if any undefined subroutine in that package is called then then the statements of this AUTOLOAD subroutine are executed.
For example in below example i have called a subroutine
&subroutine_not_present(12,23,"hi");
which is not present.When this program is executed and perl will not found the called subroutine it will call the AUTOLOAD subroutine which is present in the program.



Program Code:
#! /Perl/bin/perl

&subroutine_not_present(12,23,"hi");

AUTOLOAD
{
print("Can't find $AUTOLOAD subroutine\n");
print("Argumens to that subroutine are @_");
}


Output:




2)BEGIN Subroutine:

If the program contains any subroutine named as BEGIN then that subroutine will be executed first before executing any other statement of that program.A program can have more than one BEGIN subroutine.If this is the case then these are executed on the basis of order in which they have defined.

Program Code:
#! /Perl/bin/perl

BEGIN{

print("I am printing from BEGIN subroutine\n");
print("And interesting thing is that \nwe don't need to call this routine\n");
print("It is automatically called\n");
}

BEGIN{
print("And another interesting fact about this is that there can be\n");
print("more than one BEGIN routines in a single program.\n");
print("They are called in the order in which they are specified in the program.");
}

Output:



3)END Subroutine:

This subroutine is called after the last statement of the program has been executed.A program can contain more than one END subroutine.If this is the case then these are executed in the reverse order.

Program Code:
#! /Perl/bin/perl
END{
print("And another interesting fact about this is that there can be\n");
print("more than one END routines in a single program.\n");
print("They are called in the opposite order in which they are specified in the program."); 
}
END{
print("I am printing from END subroutine\n");
print("And interesting thing is that \nwe don't need to call this routine\n");
print("It is automatically called\n");
}


Output:




  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Ad


Jobsmag.inIndian Education BlogThingsGuide

Subscribe

Do you want fresh and hot updates about us? Then subscribe to our Feeds.

Total Pageviews

Popular Posts

  • Write a program in PL/SQL to print the factorial of a number.
    In this post I will explain how to get the factorial of any given number. For that first you need to know what is the procedure to find ...
  • To find the GCD of two numbers in PROLOG.
    gcd(X,Y):-X=Y,write('GCD of two numbers is '),write(X); X=0,write('GCD of two numbers is '),write(Y); Y=0,write('G...
  • Write a PL/SQL code to get the Fibonacci Sequence
    First, I will explain what is Fibonacci Sequence and how to get this series. So, Fibonacci Sequence is a series of numbers 0,1,1,2,3,5,8,1...

Label

All Articles Best Resources Blogging Boost Traffic Bootstrap C Plus Plus Collection Comedy Comedy Posts Comedy Videos Concurrency creative commons website Education Employee Entertainment Fibonacci Sequence free images GirlFriend Hinglish Cafe How To Image Websites Inspirational Java Java Interview Questions Java Networking Kavita Sangrah Life Lock Sreen Love Number System Patterns Perl Picture PL/SQL Plastic Engineering Programming Prolog public domain SEO Servlet Short Story Shortcut Keys Social Media Social Services SQL SuVichar Thread Traffic True Events Ultimate Guide Windows Tricks Windows8.1 WordPress

Blog Archive

  • ►  2020 (43)
    • ►  September (41)
    • ►  August (2)
  • ►  2019 (1)
    • ►  July (1)
  • ►  2018 (9)
    • ►  September (7)
    • ►  July (1)
    • ►  May (1)
  • ►  2017 (8)
    • ►  June (3)
    • ►  May (3)
    • ►  March (1)
    • ►  January (1)
  • ►  2016 (2)
    • ►  September (1)
    • ►  January (1)
  • ▼  2015 (91)
    • ►  December (1)
    • ►  November (1)
    • ►  October (6)
    • ►  May (10)
    • ►  March (20)
    • ▼  February (50)
      • Different formats in Perl
      • Format Headers in Perl
      • File handling in Perl
      • List count in Perl
      • List all files in a directory using Perl
      • Pattern matching in Perl
      • Rand() function in Perl
      • sleep in Perl
      • Various string operations in Perl
      • Subroutines in Perl
      • Upper case to Lower Case In Perl
      • Variable Validation in Perl
      • Warn in Perl
      • die in perl
      • Sub Routines in Perl
      • Array Sorting in Perl
      • Array in perl
      • Array Functions in Perl
      • Array Functions in Perl:Chop()
      • Array Functions in Perl:Sort()
      • Array Alias in Perl
      • Arrays in Perl
      • Arithmetic Operations in Perl
      • Pagination using Bootstrap
      • Link Alerts using Bootstrap
      • Dismissable alert using Bootstrrap
      • Different types of Alerts in Bootstrap
      • Wells in Bootstrap
      • Thumbnail in Bootstrap
      • Tab links in Bootstrap
      • Push and pull in Bootstrap
      • Pill links in Bootstrap
      • Panels in Bootstrap
      • Offset in Bootstrap
      • Nested columns in Bootstrap
      • Navbars in Bootstrap
      • Media Objects in Bootstrap
      • List Groups in Bootstrap
      • Labels in Bootstrap
      • Inline forms in Bootstrap
      • Horizontal forms in Bootstrap
      • Various validation state in Bootstrap
      • Disable input in Bootstrap
      • Headers using Bootstrap
      • Glyphicons in Bootstrap
      • Dynamic layout in Bootstrap
      • Buttons in Bootstrap
      • Simple form using Bootstrap
      • Badges in Bootstrap
      • Grid Layout in Bootstrap
    • ►  January (3)
  • ►  2014 (339)
    • ►  December (1)
    • ►  October (55)
    • ►  September (58)
    • ►  August (94)
    • ►  July (64)
    • ►  June (67)
  • ►  2013 (34)
    • ►  August (5)
    • ►  April (29)
  • ►  2012 (20)
    • ►  November (1)
    • ►  October (15)
    • ►  September (4)

Author

  • Earthcare Foundation NGO
  • Kavita house
  • Unknown
  • Unknown

Info

Copyright © Hub Of Geekz | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates