Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

difference between modules and package

by gautam_9jan (Initiate)
on Mar 06, 2011 at 09:16 UTC ( [id://891654]=perlquestion: print w/replies, xml ) Need Help??

gautam_9jan has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: difference between modules and package
by GrandFather (Saint) on Mar 06, 2011 at 10:23 UTC

    A module is a Perl source file with a .pm extension. Generally modules are used as library files and can be loaded using use or require.

    package is a way of providing a namespace for a section of code. The package name acts as a prefix for identifiers within the namespace. For example if a section in a Perl source file contains package Foo; followed by sub bar {} the sub can be accessed by code outside the Foo packaged as Foo::bah. Multiple sections of code may have the same package name and are treated as being all in the same namespace.

    Modules generally contain a package statement with the same name used as the name of the module (excluding the .pm extension). Modules can however contain more than one package and don't need to contain any - not even a package that matches the module name.

    Oh, and you can uses packages in a Perl script file (often with a .pl extension) - a package statement doesn't have to be in a module file. If no package statement is used the package name is 'main'.

    True laziness is hard work
Re: difference between modules and package
by Anonymous Monk on Mar 06, 2011 at 09:23 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://891654]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-16 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found