Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Pass array, then clear

by ikegami (Pope)
on Jan 17, 2018 at 05:03 UTC ( #1207395=note: print w/replies, xml ) Need Help??


in reply to Re^2: Pass array, then clear
in thread Pass array, then clear

I did not suspect that the subroutine made a copy of the memory address.

It doesn't (though you did in the first line of the sub).

I figured that by passing in a reference, then whatever I did to the reference would reflect the new state of the reference.

You didn't do anything to the reference. (You changed the value of $data.)

Also, there isn't really anything you can do to a reference. You can't change a reference any more than you can change 5.

Suppose the variable passing used some sort of "slot based" mechanism where the caller/sub could agree on variables (references) in and their value (slot) on return?

That is what happens. You didn't change any of the slots (elements of @_).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1207395]
help
Chatterbox?
and the universe expands...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-05-25 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?