The code simplifies to:
modifyHash(\%my_hash); sub modifyHash { my $hash_ref = shift; # Do something to the hash ${$hash_ref}{'test'} = 1; #$hash_ref->{'test'} = 1; #alternative }
basically, use {$hash_ref} wherever my_hash would have appeared:
%my_hash -> %{$hash_ref} keys(%my_hash) -> keys(%{$hash_ref}) %my_hash = (); -> %{$hash_ref} = () $my_hash{$key} -> ${$hash_ref}{$key}
In reply to Re: Modifying a hash in a subroutine?
by ikegami
in thread Modifying a hash in a subroutine?
by C_T
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |