Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2018-02-24 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (311 votes). Check out past polls.

    Notices?