Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Better way to define global variables

by Athanasius (Abbot)
on Jul 25, 2013 at 14:03 UTC ( #1046349=note: print w/ replies, xml ) Need Help??


in reply to Better way to define global variables

Ok, you now know how to do this. Here’s why you shouldn’t! From Exporter#What-Not-to-Export:

Do not export variable names. Just because Exporter lets you do that, it does not mean you should.

@EXPORT_OK = qw( $svar @avar %hvar ); # DON'T!

Exporting variables is not a good idea. They can change under the hood, provoking horrible effects at-a-distance, that are too hard to track and to fix. Trust me: they are not worth it.

To provide the capability to set/get class-wide settings, it is best instead to provide accessors as subroutines or class methods instead.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re: Better way to define global variables
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2015-07-30 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls