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

One point to clarify is that the reason it bugs me, apart from wanting vars to only live within the scope where they are needed, is that I might re-use the name $vrx later, with possible side-effects.

If you use warnings, you'll get a warning if you redefine a new my $vrx in the same scope as the first. If it's not in the same scope, then it'll be a different $vrx, so there should be little to no chance of unintended side-effects.

Of course, the better way to deal with it would be to use a more meaningful/distinctive name so that it's unlikely that you'll have cause to re-use the name...

Replies are listed 'Best First'.
Re^4: Avoiding Global Vars
by Melly (Chaplain) on Sep 23, 2009 at 15:29 UTC

    Ah, but I might (stupidly) do something like:

    my $urx = 0; # no warning on mistyped $vrx
    print $vrx; # get's old $vrx
    

    As for more meaningful/distinctive, vrx, for reasons relating to the specific tech I'm working with, is very meaningful...

    Thanks again.

    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