Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL import Function
Syntax
Definition and Usage
There is no builtin import function. It is just an ordinary method (subroutine) defined (or inherited) by modules that wish to export names to another module. The use function calls the import method for the package used.
Return Value
Example
Try out following example:
#!/usr/bin/perl
package Util;
use base 'Exporter';
our @EXPORT_OK = ('foo', 'bar');
sub foo {
print "foo!";
}
sub bar {
print "bar!";
}
package Amy;
use Util 'foo'; # only import foo()
foo(); # works fine
bar(); # blows up
|
|

|
|
|