Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: What is module? Difference between module and package?

by polypompholyx (Chaplain)
on Oct 28, 2005 at 07:44 UTC ( #503584=note: print w/ replies, xml ) Need Help??


in reply to What is module? Difference between module and package?

A module is a .pm file containing some Perl code. A package is a declaration of the name of the current scope, e.g.:

package Math::Complex

which can occur in the code of a module or a script. A module can be used, because it is a physical 'thing', but a package cannot. A module may contain several packages: CPAN does this. The advantage is that the code inside that module can still be chunked up into classes/etc. by package declarations, as if these classes were separate modules, but that the functionality is still lumped into a single convenient file.


Comment on Re: What is module? Difference between module and package?
Select or Download Code
Re^2: What is module? Difference between module and package?
by liz (Monsignor) on Oct 28, 2005 at 11:54 UTC
    Please note that package is scoped:
    package Foo; print __PACKAGE__,$/; { package Bar; print __PACKAGE__,$/; } print __PACKAGE__,$/; __END__ Foo Bar Foo
    with the default scope being the file, or course (although you rarely have to think about things like that, fortunately).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://503584]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2015-07-07 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls