No such thing as a small change | |
PerlMonks |
Re: Avoiding variable conflict when importing modulesby btrott (Parson) |
on Jun 25, 2001 at 02:40 UTC ( [id://91139]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|