I've been wanting to learn how to create modules for a while so I decided to print up all the information I could Google and find in here (which wasn't very much, mind you) but it looks like my Perl Blackbook has some information on it.

I just have a few basic questions that I'm sure the monks here wouldn't have any problem answering.

The only difference between a package and a module is the extension of .pm and and the module requires the package name? Is that right?

A module is nothing more than Perl code it looks like. I thought it was a lot different from looking at some posts in here showing them. I guess what made me think they were more complicated was the =HEAD NAME and =HEAD DESCRIPTION type headings. The example I was looking at is Text::Tab since it's a small module and this appears at the BOTTOM of the script. Are these required and what are their purpose? The tutorials I found didn't list these and I don't believe this is induced in the script. Maybe it's just for people to read when they view the source code?

Now comes down to the theory behind using modules.. I know there is a difference between use and require, but when it comes to using variables inside the module should we be using $_ or @_ more often than predefined names? Or how does our data imported from our script into the module if it requires specific names? (note: I know some modules have their own variables to use).

Thanks for all your help, wise monks! I'm sure when I venture deeper into this I'll have more questions on the topic.



"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to Creating modules by sulfericacid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.