Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: passing a hash ref in a sub

by pDaleC (Sexton)
on Nov 01, 2018 at 13:54 UTC ( [id://1225055]=note: print w/replies, xml ) Need Help??


in reply to passing a hash ref in a sub

I would suggest you make the hash the return value of the function:
sub unfold_hash { my ( $raw_hr ) = @_; my %res; for my $k ( keys %$raw_hr ) { $res{$k} = $raw_hr->{$k}; } print "unfold_hash ", %res ? scalar %res : 0, "\n"; \%res; } $result_hr= unfold_hash($data); print Dumper $result_hr;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found