Thursday, June 21, 2012

Perl Functions & Subroutines:

Below are some of the perl functions:

Function name                                                     Description
abs                                                                        returns the absolute value of the argument

alarm                                                                    alarm(seconds)
                                                                             Sends a Sigalarm signal after a number of seconds

atan2                                                                    atan2< X, Y>
                                                                            returns the arctangent of X/Y in the range <pi>.

chmod                                                                 chmod(MODE , LIST)

                                                                            changes the permissions list of files
dump                                                                   causes an immediate binary  image core dump.
many more......

Subroutines:
In addition to above inbuilt functions in perl , you can create your own subroutines or functions. Subroutines are the self-contained units of program designed to accomplish a specified task.

Subroutine declaration:
       sub subroutine_name;

Subroutine_definition:
      sub subroutine_name {Block}

NOTE:Subroutines can be defined anywhere in your program or even in another file.

Subroutine Call:
      do subroutine_name;
      &subroutine_name;
      subroutine_name();
      subroutine_name

Subroutine call with parameter:
      &subroutine_name (parameter1, paramter2,......)
      subroutine_name(parameter1, parameter2,......)

No comments:

Post a Comment