Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by chromatic (Archbishop)
on Jul 31, 2001 at 04:02 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-24 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found