Perl Data structures - Hash of Arrays
Method 1:
$HoA = {
flintstones => [ "fred", "barney" ],
jetsons => [ "george", "jane", "elroy" ],
simpsons => [ "homer", "marge", "bart" ],
};
foreach (keys %{$HoA})
{
print "$_ => @{$HoA->{$_}}\n";
}
Method 2:
%HoA = (
flintstones => [ "fred", "barney" ],
jetsons => [ "george", "jane", "elroy" ],
simpsons => [ "homer", "marge", "bart" ],
);
foreach (keys %HoA)
{
print "$_ => @{$HoA{$_}}\n";
}
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home