- @AoH = (
- {
- husband => "barney",
- wife => "betty",
- son => "bamm bamm",
- },
- {
- husband => "george",
- wife => "jane",
- son => "elroy",
- },
- {
- husband => "homer",
- wife => "marge",
- son => "bart",
- },
- );
- for (@AoH)
- {
- print $$_{husband}."--------/n";
- }
- for $i ( 0 .. $#AoH ) {
- print "$i is { ";
- for $role ( keys %{ $AoH[$i] } ) {
- print "$role=$AoH[$i]{$role} ";
- }
- print "}/n";
- }
- print $AoH[0]{husband}."!!\n";
复制代码 问题来了,$AOH[0]{husband}前为什么不用加$,如果不用加,为什么keys %{ $AoH[$i] }加%,感觉矛盾啊 |