fredsnertz has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $hash_ref=set_up(); foreach $key (keys %{$hash_ref}) { $val=$$hash_ref{$key}; if (ref($val)) { print "\ntotal \'$key\' = ", scalar @{$hash_ref{$key}}, "\n"; foreach $act (@{$hash_ref{$key}}) { print "\t$act\n"; } } else { print "$key - $val\n"; } } sub set_up { my (%hash,@array); @array=("feed","walk","pet","groom"); $hash{'one'}="cat"; $hash{'two'}="dog"; push(@{$hash{'actions'}},@array); return(\%hash); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing hash refs
by kennethk (Abbot) on Apr 08, 2009 at 15:46 UTC | |
by fredsnertz (Initiate) on Apr 08, 2009 at 15:58 UTC | |
by RMGir (Prior) on Apr 08, 2009 at 16:40 UTC | |
by GrandFather (Saint) on Apr 08, 2009 at 23:19 UTC | |
|
Re: passing hash refs
by ikegami (Patriarch) on Apr 08, 2009 at 15:51 UTC | |
by fredsnertz (Initiate) on Apr 08, 2009 at 16:00 UTC |