Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

In this specific case, supplying an import list (the qw/is_valid/ part) imports that symbol, leaving it out imports nothing.

In the general case, the import list is passed to the loaded module's ->import function, and it can do whatever it wants to do.

But many, many modules are based on Exporter. For Exporter-based modules, not specifying an import list gets you all the symbols listed in the default exportation list called @EXPORT. Specifying an import list disables that default, and instead gives you the symbols you asked for, if they are listed in @EXPORT_OK. If they are not, you'll get an error.

In most cases, importing doesn't affect performance to any discernible degree, but it is often easier for maintenance to list exactly the symbols you want to import. If you have many use statements, it's easy to search for which module gave you a particular symbol.

But it is worth mentioning that a few peculiar modules (if I remember correctly, POSIX and/or CGI) have quite many symbols, and only compile the routines to be exported as requested. In this case, it can make a noticeable difference in start-up time if you import all routines.


In reply to Re: Difference between use Module::Name and use Module::Name qw /method1 method2/ by moritz
in thread Difference between use Module::Name and use Module::Name qw /method1 method2/ by Doctrin

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (3)
    As of 2014-07-14 05:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (255 votes), past polls