Works fine for me:
#! perl use strict; use warnings; my %HoH = ( Flintstone => { Father => 'Fred', Mother => 'Wilma', }, Simpson => { Father => 'Homer', Mother => 'Marge', }, ); my %HoA = ( Flintstone => [ Father => 'Fred', Mother => 'Wilma', ], Simpson => [ Father => 'Homer', Mother => 'Marge', ], ); for my $family (sort keys %HoH) { print "$family: "; for my $role (keys %{ $HoH{$family} }) { print "$role=$HoH{$family}{$role} "; } print "\n"; print "$family: @{ $HoA{$family} }\n"; }
Output:
12:09 >perl 928_SoPW.pl Flintstone: Father=Fred Mother=Wilma Flintstone: Father Fred Mother Wilma Simpson: Father=Homer Mother=Marge Simpson: Father Homer Mother Marge 12:09 >
You will need to show the exact contents of %HoH and %HoA prior to the for loop. (Use Data::Dumper or Data::Dump.)
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: What is wrong in this syntax?
by Athanasius
in thread What is wrong in this syntax?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |