in reply to Package vs. plain file

The beauty of Perl is you don't have to do it any which way. TIMTOWTDI, after all.

But I think you've gotten some concepts confused. I had trouble initially with Perl's idea of packages because I was so used to Java. Java has a one-to-one relationship between a file and its namespace. The class java.lang.String has to live in a file called "String.class" in a directory hierarchy of java/lang. Perl on the other hand allows you to switch namespaces within the same file, or use a namespace that's totally unrelated to the file the code lives in.

In practice, there usually is a correspondence between a file (like Crypt/Blowfish.pm) and the namespace it uses (Crypt::Blowfish::). But this doesn't have to be. In your example for instance, I can put somesub in a separate namespace within the same file, or load a somesub that lives in a namespace totally unrelated to the file name it is defined in:

In a file called "TestFile.pm":
package Foo::Bar; sub somesub{ return "somesub value from package Foo::Bar!"; } 1;
In a file called "test.pl":
use TestFile; package Common; sub somesub { my $value = 'somesub value from Common package!'; return $value; } package main; print "Back in main package.\n"; my $rv1 = Common->somesub(); # Defined just above in this file my $rv2 = Foo::Bar->somesub(); # Found in file TestFile.pm print "Return Value 1: $rv1\nReturn Value 2: $rv2\n";
My point being that file names and packages are very loosely coupled in Perl. Good reading for all of this is perlmod and package.