Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: passing hash ref to a function

by hippo (Bishop)
on Mar 16, 2018 at 17:08 UTC ( [id://1211065]=note: print w/replies, xml ) Need Help??


in reply to passing hash ref to a function

my %ref_hash = %{$ref};

When you do that you are creating a copy. Don't do that if you want to modify the arguments.

sub test { my ($ref) = @_; $ref->{'new'} = 'new_v'; print join(",", keys (%$ref)),"\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found