http://www.perlmonks.org?node_id=1029888

HelenCr has asked for the wisdom of the Perl Monks concerning the following question:

Dear esteemed PerlMonks

I am wrestinlg with the following issue (which may be a trivial one): how do you export functions from a package, which is not the first one in a module file? I've been searching the documentation and the Net, and can't seem to find an answer.
Here is an example:

# Name of this file: pack_A.pm package pack_A; require Exporter; @ISA = qw {Exporter}; @EXPORT = qw {first second}; sub first { } sub second { } 1; #end package pack_A; package pack_B; sub third { } sub fourth { } 1; #end package pack_B;
In the main script, I would like to use package pack_B, which sits lower in the file: pack_A.pm.
It turns out that it's not that simple. If you add the subroutines 'third' and 'fourth' to @EXPORT,
@EXPORT = qw {first second third fourth};
then in your main script, when you go:
use pack_A;
and call the 'third' sub, it will complain:
undefined subroutine &pack_A::third ...etc
(You can't go:
use pack_B;
since the interpreter looks for the file specified in "use". In other words, it will look for the module pack_B.pm, which does not exist).

Your advice will be appreciated.
Many TIA - Helen