Many modules by default export a bunch of functions into the current package (whatever has the use Mymodule; in it). By including an empty list in the use you explicitly forbid anything from Mymodule being exported into the package name space. That doesn't stop you accessing the module's functions however. You just prefix the function name with the module name: Mymodule::wibble () for example to call the wibble function from the Mymodule module.

Why bother? Well, modules tend to be designed in isolation so very often functions that perform similar tasks get the same name in different modules. If all the functions were imported from every module that is used in a package then the chance of collisions between function names becomes very high - using name spaces as above completely avoids the problem.

Another advantage of using explicit name spaces is that then it is clear where the function comes from. I always use CGI with an empty list for example and then either use the OO interface CGI provides or call functions using an explicit CGI:: prefix.


True laziness is hard work

In reply to Re: Module usage by GrandFather
in thread Module usage by vinoth.ree

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.