Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Passing Hash to Subroutine

by fx (Pilgrim)
on Dec 28, 2003 at 20:37 UTC ( [id://317332]=note: print w/replies, xml ) Need Help??


in reply to Passing Hash to Subroutine

If I pass a reference to a hash into a sub, I keep working with the reference:

some_sub(\%some_hash); sub some_sub { my $hash_ref = $_[0]; ## Now communicate with hash using: ## $hash_ref->{'SOME_KEY'} returns the value for SOME_KEY ## or ## $hash_ref->{'OTHER_KEY'} = "foo" will set a key to a value ## etc. ## Or the slightly more exciting: ## foreach $key (keys %{$hash_ref}) { ## do_something_with $hash_ref->{$key} }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found