Mega Code Archive

 
Categories / Perl / Subroutine
 

Passing hash to a subroutine

$hash{fruit} = peach; $hash{vegetable} = broccoli; $hash{pie} = blueberry; sub printem {     %hash = @_;     foreach $key (keys %hash) {         print "$key => $hash{$key}\n";     } } printem(%hash);