Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by moritz (Cardinal)
on Jan 29, 2013 at 10:44 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1015845]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-26 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found