Mega Code Archive

 
Categories / Perl / Subroutine
 

Return hash value from subroutine

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