Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Pass array, then clear

by ikegami (Patriarch)
on Jan 17, 2018 at 05:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1207395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-19 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found