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.
In reply to Re^3: Understanding typeglobs and local()
by dave_the_m
in thread Understanding typeglobs and local()
by whio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |