Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Avoiding variable conflict when importing modules

by btrott (Parson)
on Jun 25, 2001 at 02:40 UTC ( #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.

  • Comment on Re: Avoiding variable conflict when importing modules

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://91139]
[Discipulus]: but i'm also animalist, so i' hirted by 1nickt's sig: The way forward always starts with a mammal test... grin..
[erix]: I might if I did remember. It's probably somewhere in the site docs
[uhClem]: I don't favor that sort of thing around here but the place for our politics is wherever we live.
[uhClem]: And besides, the objection to it was off-topic.
[Discipulus]: 1nickt hide signature is a positive action; i think is not a solution here
[erix]: my objection to sigs is just that they take screen space. ( Some monks would have *several* slogans underneath a 1-liner reply )

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-06-22 12:36 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.