Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Difference between use Module::Name and use Module::Name qw /method1 method2/

by moritz (Cardinal)
on Jan 29, 2013 at 10:44 UTC ( #1015845=note: print w/replies, xml ) Need Help??

in reply to Difference between use Module::Name and use Module::Name qw /method1 method2/

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015845]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2018-07-17 02:32 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (353 votes). Check out past polls.