Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Exporting functions into main namespace for the benefit of other use'd modulesby halley (Prior) |
on Jul 10, 2003 at 20:04 UTC ( [id://273118]=note: print w/replies, xml ) | Need Help?? |
There's a namespace called main and there's a namespace called CORE. All the builtins are in CORE, while anything in the initial script are in main. When you give &::foo, it's really seen as &main::foo.
If you really wanted to make something available to everything, you'd alias it into the CORE namespace. Some modules like the File::Glob actually do this if you ask for it explicitly, but it's quite dangerous to do this willy-nilly. In general, you should export symbols to your caller, not to the world. You might not know how large or diverse your runtime world really is, and other modules in this runtime world may not be expecting your changes. If they like your exports, they can use your module to get them. --
In Section
Seekers of Perl Wisdom
|
|