in reply to Packages and Modules


Multiple package statements are allowed in the same module. Here's an example below:
$ cat My/Own/Package.pm package My::Own::Package; sub foo { 'in My::Own::Package' } package My::Other::Package; sub foo { 'in My::Other::Package' } 1; $ ls My/Other/* ls: My/Other/*: No such file or directory $ cat print_foo.pl #!/usr/bin/perl use warnings; use strict; use lib qw(.); use My::Own::Package; print "calling My::Own::Package::foo() returns: " . My::Own::Package::foo() . "\n"; print "calling My::Other::Package::foo() returns: " . My::Other::Package::foo() . "\n"; $ print_foo.pl calling My::Own::Package::foo() returns: in My::Own::Package calling My::Other::Package::foo() returns: in My::Other::Package

Notice that use My::Own::Package; only tells Perl to load the appropriate My/Own/Package.pm module file. The module itself can do anything it wants (like installing a function in package My::Other::Package).