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} }
In reply to Re: Passing Hash to Subroutine
by fx
in thread Passing Hash to Subroutine
by mjmaresca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |