GreyOwl has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl5 -w ########################################################## %fred = (1 => "un", 2 => "deux", 3 => "trois"); %mary = (1 => "eins", 2 => "zwei", 3 => "drei"); print "\nfred:"; for (keys %fred) {printf "\t%3s: %-8s", $_, $fred{$_}}; print "\nmary:"; for (keys %mary) {printf "\t%3s: %-8s", $_, $mary{$_}}; print "\n"; @nm = qw(fred mary); for $n (@nm) {print "\n$n:"; for (keys %{$n}){printf "\t%3s: %-8s", $_, ${$n}{$_}}} my %fred1 = (1 => "yksi", 2 => "kaksi", 3 => "kolme"); my %mary1 = (1 => "uno", 2 => "due", 3 => "tre"); use strict; my @nm1 = qw(fred1 mary1); print "\n"; for my $n (@nm1) { print "\n$n:"; for my $m (keys %{$n}) { printf "\t%3s: %-8s", $m, ${$n}{$m}; } } print "\n"; __END__ (svmoloch:szhxrv) $ ./test_hashname.pl fred: 1: un 2: deux 3: trois mary: 1: eins 2: zwei 3: drei fred: 1: un 2: deux 3: trois mary: 1: eins 2: zwei 3: drei Can't use string ("fred1") as a HASH ref while "strict refs" in use at + ./test_hashname.pl line 27. fred1:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: string as a HASH ref
by hardburn (Abbot) on Jun 18, 2003 at 14:22 UTC | |
|
Re: string as a HASH ref
by tall_man (Parson) on Jun 18, 2003 at 14:22 UTC | |
|
Re: string as a HASH ref
by ant9000 (Monk) on Jun 18, 2003 at 14:17 UTC | |
|
Re: string as a HASH ref
by Bilbo (Pilgrim) on Jun 18, 2003 at 14:25 UTC | |
|
Re: string as a HASH ref
by GreyOwl (Initiate) on Jun 18, 2003 at 15:22 UTC |