Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

package vs module?

by littlemonk (Sexton)
on Mar 25, 2014 at 18:41 UTC ( [id://1079720]=perlquestion: print w/replies, xml ) Need Help??

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

what is the difference between module and package?..please help!

Replies are listed 'Best First'.
Re: package vs module?
by toolic (Bishop) on Mar 25, 2014 at 18:45 UTC
Re: package vs module?
by karlgoethebier (Abbot) on Mar 25, 2014 at 19:06 UTC
    "...please help!"

    Yes...please read Perl_module and then build your first own Perl module.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re: package vs module?
by Anonymous Monk on Mar 25, 2014 at 20:07 UTC
Re: package vs module?
by zentara (Archbishop) on Mar 26, 2014 at 10:18 UTC
    For a beginner level view, which gets you thru most cases, a package is used inline with the main source code; whearas when you want to put the package into a separate file, you call it a module. The nice thing about inline packages is that you don't need to worry about the location of the external file. Both ways allow you to create objects, or import functions and constants. It gets complicated, but the workings are very simple. As a matter of fact, you can take most conventional Perl modules and rip them apart into various packages and insert them directly into your script.

    I know this is over-simplified, but that is the answer I would have wanted to hear when I was first learning.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
        Thanks for providing the example link, but I posted my response as just a quick overview of what I see as the difference, in case the OP is not technically inclined enough to understand the Simple Module Tutorial. I remember when I first started to learn Perl, back around 1998, I didn't give a thought to what objects were, or how they got there, back in those days, most scripts were written mostly as a monolithic collection of functions. Objects only confused beginners back then.

        I also just passed up reading all the links you posted, and failed to realize that what I said, was basically the topic of the Simple Module Tutorial, but in far less words. . Mea Culpa, Mea Culpa, Mea Maxima Culpa!. :-)


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh
Re: package vs module?
by sundialsvc4 (Abbot) on Mar 26, 2014 at 01:59 UTC

    Unfortunately for you, this distinction is mostly “an ambiguity or a confusion of terms.”   In general (human-being ...) usage, these two words are pretty-much interchangeable.   In the Perl language, though, package is a keyword and module is not.

    Therefore, just consider the idea:   Namely, that a great-big program can be subdivided into pieces, each one preceded by the package keyword, and that you can incorporate those pieces into other pieces by means of use.   That’s “the big picture.™”   Nevermind the terminology.   The language-designers, long ago, had to choose one word versus the other.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found