Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^10: Does @{ } copy arrays?

by QM (Vicar)
on Oct 30, 2009 at 14:22 UTC ( #804170=note: print w/ replies, xml ) Need Help??


in reply to Re^9: Does @{ } copy arrays?
in thread Does @{ } copy arrays?

OK, I think I understand most of those examples.

Except foo($#a) has me scratching my head. It's marked modifiable, but it's not a reference (at least not obvious to me). Maybe this is the older, darker magic of the aliasing involved with @_ in subs? (Personally, I avoid coding in such an implicit way, preferring to catch the passed arguments explicitly.)

I went back an read most of the thread, and, while much of the discussion was over my head, it seems that those in the know are trying to fix it appropriately (or have already done so).

Thanks to all for a mind-expanding discussion.

-QM
--
Quantum Mechanics: The dreams stuff is made of


Comment on Re^10: Does @{ } copy arrays?
Select or Download Code
Re^11: Does @{ } copy arrays?
by ikegami (Pope) on Oct 30, 2009 at 14:55 UTC
    Params are passed by reference. The elements of @_ are aliased to the arguments passed.
    >perl -le"sub f { $_[0]=456; } $x=123; f($x); print $x;" 456
    >perl -le"sub f { $_[0]=3; } $#a=2; f($#a); print $#a;" 3

    it seems that those in the know are trying to fix it appropriately (or have already done so).

    I wrote a fix. It was reviewed by Rafael who fixed a big in it and committed it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2014-08-30 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls