Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 had had some important initialization it only did in its import sub, that would be missed.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-08-19 18:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found