Elements of @_ are aliased to EXISTING/DEFINED elements of the passed parameter.Not necessarily.
perl -MData::Dump::Streamer -le '@ary = (); x($ary[5],"foo"); sub x { +$_[0] = $_[1] }; Dump(\@ary)' $ARRAY1 = [ ( undef ) x 5, 'foo' ]; perl -MData::Dump::Streamer -le '@ary = (); x($ary[5],"foo"); sub x { +$_[0] }; Dump(\@ary)' $ARRAY1 = [];
As you can see, the element at index 5 is not created merely by passing its alias to the sub. It doesn't exist and isn't defined, and may remain so after the sub has been called.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re^4: perlsub question..
by shmem
in thread perlsub question..
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |