Perl require Function

Advertisements


Description

This function then it demands that the script requires the specified version of Perl in order to continue if EXPR is numeric. 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.

Syntax

Following is the simple syntax for this function:

require EXPR

require

Return Value

This function does not return any value.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl -w

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

# require to include amodule.
require Module;

..............

When above code is executed, it produced following result




Advertisements
Advertisements