Dies ist eine alte Version des Dokuments!
@AoH = ( { husband => "barney", wife => "betty", son => "bamm bamm", }, { husband => "george", wife => "jane", son => "elroy", }, { husband => "homer", wife => "marge", son => "bart", }, );
Hinzufügen eines hash zum array:
push @AoH, { husband => "fred", wife => "wilma", daughter => "pebbles" };
Einlesen einer Datei im Format „husband=fred friend=barney“ mit einer der folgenden Schleifen:
while ( <> ) { $rec = {}; for $field ( split ) { ($key, $value) = split /=/, $field; $rec->{$key} = $value; } push @AoH, $rec; } while ( <> ) { push @AoH, { split /[\s=]+/ }; }
Innerhalb einer Subroutine 'get_next_pair', das eine key/value Paar liefert.
while ( @fields = get_next_pair() ) { push @AoH, { @fields }; } while (<>) { push @AoH, { get_next_pair($_) }; }
Anhängen neuer Einträge an ein existierendes hash:
$AoH[0]{pet} = "dino"; $AoH[2]{pet} = "santa's little helper";