in reply to Re: Re: Scope Between global and my
in thread Scope Between global and my
is functionally equivalent to:{ local $x = 3; do_stuff(); }
The problem with local is that it LOOKS like some handy keyword for creating locally scoped variables. But some do_stuff() might not be expecting this suppression, and they might not realize that the suppression will end without their control. No matter what do_stuff() does, the value of $x will be reverted at the end of this code's scope.{ my $secret_name_1095471 = $x; $x = 3; do_stuff(); $x = $secret_name_1095471; }
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Scope Between global and my
by jdporter (Paladin) on Apr 02, 2004 at 16:35 UTC | |
by TimToady (Parson) on Apr 02, 2004 at 18:12 UTC | |
by adrianh (Chancellor) on Apr 02, 2004 at 20:29 UTC |