Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: NEVER do this. Ever. Not even once.

by chromatic (Archbishop)
on Jul 31, 2001 at 04:02 UTC ( #101022=note: print w/ replies, xml ) Need Help??


in reply to Re: NEVER do this. Ever. Not even once.
in thread Variable Scope

I understood dragonchild to mean that using $::somevar is an awful practice. I quite agree. What's the point of telling Perl, "I want you to alert me to potentially hazardous programming" when you go out of your way to violate it?

As for global variables, they're hard to track down, they can have unfortunate side effects, they can make your code difficult to follow, they break encapsulation, they reduce reusability, and they can lead to severe contortions when you add new things.

That's not to say that they're forbidden. bikeNomad points out a place where it's absolutely necessary. It's even useful.

It's just that, in general, the places where you really need to use global variables are few and far between. Appropriately scoped lexicals exist for a reason.


Comment on Re: Re: NEVER do this. Ever. Not even once.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-08-28 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (254 votes), past polls