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
    I think this is related to some optimization. Some people like to use $#array = ... because it is faster than explicitly filling the array.

    Oh those naughty "some people"; using a defined language feature in the way it was designed.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.