Perl use Function



Description

This function imports all the functions exported by MODULE, or only those referred to by LIST, into the name space of the current package. Effectively equivalent to −

BEGIN {
require "Module.pm";
Module->import();
}

Also used to impose compiler directives (pragmas) on the current script, although essentially these are just modules anyway.

Note that a use statement is evaluated at compile time. A require statement is evaluated at execution time.

If the VERSION argument is present between Module and LIST, then the use will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class.

Syntax

Following is the simple syntax for this function −

use MODULE LIST

use MODULE

use VERSION

Return Value

This function does not return any value.

Example

Following is the example code showing its basic usage −

use constant;
   use diagnostics;
   use integer;
   use sigtrap  qw(SEGV BUS);
   use strict   qw(subs vars refs);
   use subs     qw(afunc blurfl);
   use warnings qw(all);
   use sort     qw(stable _quicksort _mergesort);
   use v5.6.1;		# compile time version check
   use 5.6.1;		# ditto
   use 5.006_001;	# ditto	
perl_function_references.htm
Advertisements