Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1207395]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-08-16 13:41 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (167 votes). Check out past polls.