Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://101022]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-06-17 22:33 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.