Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Think about Loose Coupling
 
PerlMonks  

Re^3: Trying to create a common "variable library"

by almut (Canon)
on Jul 21, 2010 at 05:03 UTC ( #850555=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Trying to create a common "variable library"
in thread Trying to create a common "variable library"

... the functionality provided by this pragma has been superseded by "our" declarations ...

The thing is that the extra file implies a separate lexical scope, so you can't use our (without additional hoops), because its effect is lexically scoped.  Even if the docs call use vars "superseded", it still has its occasional uses, because the functionality isn't the same as "our" in every respect.

In the particular case of what the OP wants to use this for (i.e. having some common variable definitions to be included in several scripts), I don't really see an advantage of creating a "proper" module as you call it, i.e. putting the global variables in a different namespace first, only to then alias them all into the current package using Exporter.  As long as there's nothing else in the module, where's the benefit?


Comment on Re^3: Trying to create a common "variable library"
Select or Download Code
Re^4: Trying to create a common "variable library"
by fullermd (Curate) on Jul 21, 2010 at 13:57 UTC
    Even if the docs call use vars "superseded", it still has its occasional uses, because the functionality isn't the same as "our" in every respect.

    No, that's what Exporter is for.

    As long as there's nothing else in the module, where's the benefit?

    In this very specific, narrow case, probably not much. But specific, narrow cases have very bad habits of becoming general, larger cases on their own, as well as being physically or mentally cut&pasted into larger cases. So when the cost of doing it "cleanly" is so small (one package line and two Exporter lines), I think it's well worthwhile.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-04-19 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (480 votes), past polls