in reply to Re^2: Understanding typeglobs and local()
in thread Understanding typeglobs and local()
From what I understand, local ($_); is roughly equivalent to:No, its actually equivalent tomy $saved = $_; $_ = undef; ... $_ = $saved;
as can be seen from the following:my $tmp; my $old = \$_; *_ = \$tmp; ... *_ = \$old;
In your example they both would have printed 2.$ perl -le '$x = 1; $r = \$x; local $x=2; print "$$r $x"' 1 2 $
Dave.
|
|---|