Tuesday, January 11, 2011

PERL Functions






Definition and Usage

If EXPR is numeric, then it demands that the script requires the specified version of Perl in order to continue. If EXPR or $_ are not numeric, it assumes that the name is the name of a library file to be included. You cannot include the same file with this function twice. The included file must return a true value as the last statement.
This differs from use in that included files effectively become additional text for the current script. Functions, variables, and other objects are not imported into the current name space, so if the specified file includes a package definition, then objects will require fully qualified names.
The specified module is searched for in the directories defined in @INC, looking for a file with the specified name and an extension of .pm.

Return Value

  • Nothing

Example

Try out following example:
#!/usr/bin/perl -w

# require to demand a particular perl version.
require 5.003;

# require to include amodule.
require Module;
Perl_Programming_Tutorial

Tags: perl, functions
Source: http://www.tutorialspoint.com/perl/perl_require.htm

No comments:

Post a Comment

Labels