Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: calling module with empty import

by gaal (Parson)
on May 17, 2007 at 07:25 UTC ( #615945=note: print w/ replies, xml ) Need Help??


in reply to calling module with empty import

Export/import happens in Perl by convention: "use Module" calls Module::import, which typically does some initialization and places symbols in the caller's namespace.

It's recommended that module authors not export things by default, but some modules don't follow that recommendation. For example, YAML exports Dump and Load. What if your code already defines subs with those names? You still want to be able to use YAML's functions, e.g. by saying YAML::Dump($obj), but you don't want the default import. So you "import" (), and YAML::import never gets called. Note that if YAML.pm had had some important initialization it only did in its import sub, that would be missed.


Comment on Re: calling module with empty import
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-11-26 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls