in reply to Re: Reassigning $_ in loop doesn't stick
in thread Reassigning $_ in loop doesn't stick
This is totally wrong!
It's even documented. Just like @array returns its elements as aliases,
grep returns aliases into the original list
$ perl -MDevel::Peek -e' my $x; Dump $x; Dump $_ for $x; Dump grep 1, $x; Dump do { $x }; Dump map $_, $x; Dump sub { $x }->(); Dump eval { $x }; ' 2>&1 | grep 'SV =' SV = NULL(0x0) at 0x814ecdc # Address of $x SV = NULL(0x0) at 0x814ecdc # for aliases SV = NULL(0x0) at 0x814ecdc # grep aliases SV = NULL(0x0) at 0x814ecdc # do aliases SV = NULL(0x0) at 0x814ed9c # map copies SV = NULL(0x0) at 0x814f7f8 # sub copies SV = NULL(0x0) at 0x814ed9c # eval copies
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reassigning $_ in loop doesn't stick
by Limbic~Region (Chancellor) on Jan 21, 2009 at 21:24 UTC | |
by kyle (Abbot) on Jan 21, 2009 at 21:31 UTC | |
by ikegami (Patriarch) on Jan 21, 2009 at 21:33 UTC | |
by Limbic~Region (Chancellor) on Jan 21, 2009 at 23:58 UTC | |
by ikegami (Patriarch) on Jan 22, 2009 at 05:19 UTC |