Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: deferencing an hash in a subroutine

by BioLion (Curate)
on Aug 20, 2010 at 15:09 UTC ( #856297=note: print w/ replies, xml ) Need Help??


in reply to deferencing an hash in a subroutine

In neither of your examples are you using a reference. Try something more like:

use strict; use warnings; my %hash = (foo => 1, bar => 2,); # pass reference to subroutine test(\%hash); ########## SUB ######### sub test{ my $reference = shift; # reference is passed in @_ print "REF: $reference\n"; print "KEY: " . $_ . " VAL: " . $reference->{$_} . "\n" for (keys +%$reference); }

Check out perlref and References quick reference for more info on references and dereferencing! HTH!

Just a something something...


Comment on Re: deferencing an hash in a subroutine
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2014-07-26 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls