[mylibrary1.pl]
sub half {
my $number = shift;
return $number / 2;
}
####
[mylibrary1.pm]
package mylibrary1;
use base 'Exporter';
use vars qw( @EXPORT @EXPORT_OK );
@EXPORT = qw( half ); # These are the ones that are imported if nothing is specified.
@EXPORT_OK = qw( half ); # These are the ones you may specify, if you want.
sub half {
my $number = shift;
return $number / 2;
}
1; # All .pm files must end with a true value
__END__
####
[myscript.pl]
require 'mylibrary1.pl';
print half( 10 ), "\n";
####
[myscript.pl]
use mylibrary1 qw( half );
print half( 10 ), "\n";
####
use Foo; # Imports everything in @EXPORT, nothing in @EXPORT_OK
use Foo 'bar'; # Imports 'bar' if it's in @EXPORT_OK. Imports nothing from @EXPORT
use Foo (); # Imports NOTHING from either.