in reply to Re^5: What does my @x= (undef)x7; do?
in thread What does my @x= (undef)x7; do?
You do realise that you aren't passing the array into modify()? You're passing a list. And that list is being aliased.
Yes I do :) It's a list of aliases, just like in the subroutine GetVolumeInformation from the original post.
p5p have buggered Perl5 in their attempts to 'be correct'.
I think this is related to some optimization. Some people like to use $#array = ... because it is faster than explicitly filling the array. However this optimization comes with a cost.
Assigning to the length does not put any SVs into the new elements, and this is why you cannot create references or aliases to them. I thought there was something about this in the documentation, but I cannot find it any more (only a related section in perlguts)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: What does my @x= (undef)x7; do?
by BrowserUk (Patriarch) on Nov 10, 2015 at 11:34 UTC |