Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
November 21, 2008, 2:51 am
rate this thread
In this webpage, the package name is the same as the filename.
I checked some perl modules, it seems that the filename is always the
same as the package name. I'm wondering if this is required. Or the
package name and the filename can be different?
Re: Dose package name has to be the same as the filename? (for OO)
It's not absolutely required, but import() won't work if they're
different. OO doesn't rely on import.
You can have multiple packages per file, and they may all be different
from the module file name.
So no, it's not required, but it's a habit likely to reduce the chance
of name clashes: if package name and file name are the same, and you kow
your file name is unique, then the package name will be unique too. Heh.
Besides, why wouldn't you pick the same name? You obviously must be
somewhat happy with it, or you wouldn't pick it for either. So giving
them both the same name doesn't seem so bad.
- » FAQ 7.19 What's the difference between deep and shallow binding?
- — Previous thread in » PERL Discussions