in reply to nuances of my, and maybe local
my $fred = "foo"; for (my $idx = 1; $idx <= 10; $idx++) { local $fred; $fred = $fred x $idx; print $fred, "\n" # foo, foofoo, foofoofoo... } print $fred, "\n"; # foo
So once your for loop is done, even though you kept modifying fred each time, at the end of the loop, fred is still "foo".
EDIT: Apparently my understanding of local was not correct. Live and learn. If somone would delete this post I would appreciate it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: nuances of my, and maybe local
by diotalevi (Canon) on Sep 27, 2002 at 17:35 UTC | |
|
Re: Re: nuances of my, and maybe local
by shotgunefx (Parson) on Sep 27, 2002 at 17:31 UTC | |
by Anonymous Monk on Sep 27, 2002 at 21:16 UTC | |
by shotgunefx (Parson) on Sep 28, 2002 at 02:59 UTC | |
|
Re: Re: nuances of my, and maybe local
by Helter (Chaplain) on Sep 27, 2002 at 17:32 UTC | |
|
Re: Re: nuances of my, and maybe local
by Helter (Chaplain) on Sep 27, 2002 at 17:39 UTC |