in reply to Possibly Stupid OOP question
That is correct. Since packages almost always have a one-to-one relationship with .pm files which share the same name, it's easy to start thinking of them as interchangable, but they're not.
use specifies a file to read, no more and no less. The package(s) contained within that file are defined solely by the package statement(s) it contains.
For example, if you have a file named Foo.pm containing
then you would load its contents with use Foo, but execute them with Bar::hi. This is, obviously, a little confusing in most cases, which is why the convention of using the same name for the file and the package exists. But it's just a convention, not something enforced (or even recognized) by the language.package Bar; use strict; use warnings; sub hi { print "Hello, world!\n"; } 1;
|
|---|