This section provides a tutorial example on how to access identifiers from another package as aliases, *identifier = *package::identifier.
Instead of asking all the calling packages to define aliases, Perl offers
a solution to help package to export identifiers (symbols) automatically to the calling
packages. Perl offers a helping package called Exporter, which can be used
to help your package to define aliases into the calling packages.
To prepare a package to export identifiers (symbols), you need to add the following
lines:
package ModuleName;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(...); # symbols to export by default
@EXPORT_OK = qw(...); # symbols to export on request
To import identifiers (symbols) from an included package, you need to use the
"use" statement in one of the following formats:
use ModuleName; # import default symbols into my package
use ModuleName qw(...); # import listed symbols into my package
use ModuleName (); # do not import any symbols
Let's see how I improved my old package to use Exporter. Here is the
calendar package ready to export identifier: