Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: calling module with empty import

by gaal (Parson)
on May 17, 2007 at 07:25 UTC ( [id://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.