declaring the subroutine as sub change(\%){ will send the values as a referenceuse strict; use warnings; my %list=("bob" =>123, "tom" => "CAT"); sub change(\%){ my $temp = shift; foreach (keys %$temp){ print $_. " = $$temp{$_}\n"; $$temp{$_} .= "hello"; } } change (%list); foreach (keys %list){ print "$_ = $list{$_}\n"; }
In reply to Re^3: referances of hashes, and subroutines
by zer
in thread referances of hashes, and subroutines
by tempest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |