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

Re^2: Avoiding Global Vars

by Melly (Hermit)
on Sep 22, 2009 at 17:01 UTC ( #796760=note: print w/ replies, xml ) Need Help??


in reply to Re: Avoiding Global Vars
in thread Avoiding Global Vars

But if I only declare $vrx within the while loop, then I will lose its value when I need to print it...

Try it with the data I supplied, and look at the different output...

1001foo 1002bar 1003hello 2001bish 2002bash

versus

1foo 2bar 3hello 1bish 2bash

So, it's not a question of whether I reference it outside the loop - rather the opposite, since if I did reference it elsewhere, then it would be global, and it wouldn't bug me... if you see what I mean.

map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
Tom Melly, pm (at) cursingmaggot (stop) co (stop) uk


Comment on Re^2: Avoiding Global Vars
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2015-07-07 09:00 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 (88 votes), past polls