Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Exporting functions into main namespace for the benefit of other use'd modules

by halley (Prior)
on Jul 10, 2003 at 20:04 UTC ( [id://273118]=note: print w/replies, xml ) Need Help??


in reply to Exporting functions into main namespace for the benefit of other use'd modules

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.

--
[ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-23 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found