Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^6: What does my @x= (undef)x7; do?

by betterworld (Curate)
on Nov 10, 2015 at 09:04 UTC ( #1147336=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-11-30 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?