Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Are global variables "bad"?

by Corion (Patriarch)
on Apr 21, 2009 at 20:59 UTC ( [id://759115]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Are global variables "bad"?
in thread Are global variables "bad"?

local only works on global variables. It puts a temporary value into the global variable until the current block is left. Also see Seven Useful Uses for Local.

Replies are listed 'Best First'.
Re^4: Are global variables "bad"?
by JavaFan (Canon) on Apr 21, 2009 at 21:21 UTC
    local only works on global variables.
    Not true. It's not even true if you meant "package" where you wrote "global".
    $ perl -wE 'my @a = (1, 2, 3); {local $a[1] = 7; say "@a";} say "@a"' 1 7 3 1 2 3

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found