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?
Uhm, no. A package is a name space, while a module is a file. A module could contain several packages (or part of packages), while a package may be defined in more than one file. It's common to have one package per module, and one file per package, but it's certainly not rare to have more than one package in a file.

From man perlmod:

Packages Perl provides a mechanism for alternative namespaces to protect packages from stomping on each other's variables. In fact, there's really no such thing as a global variable in Perl. The package statement declares the compilation unit as being in the given namespace. The scope of the package declaration is from the declaration itself through the end of the enclosing block, "eval", or file, whichever comes first (the same scope as the my() and local() opera­ tors). ... Perl Modules A module is just a set of related functions in a library file, i.e., a Perl package with the same name as the file. It is specifically designed to be reusable by other mod­ ules or programs. It may do this by providing a mechanism for exporting some of its symbols into the symbol table of any package using it, or it may function as a class defi­ nition and make its semantics available implicitly through method calls on the class and its objects, without explic­ itly exporting anything. Or it can do a little of both.

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).
Huh? I don't understand the reasoning about this question. You don't program in another language if you write a module. It's still Perl, you just use an extra file, and probably a different package than "main". You'd use $_ and @_ in the same way as you would do if you wrote your code in the same file.

You may want to read some manual pages.

Abigail


In reply to Re: Creating modules by Abigail-II
in thread 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.