Dose package name has to be the same as the filename? (for OO)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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)

Peng Yu wrote:

Quoted text here. Click to load it

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.


Site Timeline