Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Avoiding variable conflict when importing modules

by btrott (Parson)
on Jun 25, 2001 at 02:40 UTC ( [id://91139]=note: print w/replies, xml ) Need Help??


in reply to Avoiding variable conflict when importing modules

In this situation, whichever function sub was imported last will be called. If you have warnings enabled, you will get a warning when importing a function that has already been defined/imported; you won't get such a warning w/ a variable (at least I don't think you will).

This is why you have to be careful when writing modules that export; you can easily trample someone else's namespace. Which is part of the reason why module authors are encouraged to use @EXPORT_OK instead of @EXPORT; you give the user of your module the choice of which functions/variables he/she imports, plus you make it very explicit to any reader of your code (including you :) which functions and variables you're importing. Ie. you can look at the use line and *know* what you're importing into your namespace.Server Error (Error ID 2448139a2052192)

An error has occurred. The site administrators have been notified of the problem and will likely soon fix it. We thank you, for you're patients.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-29 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found