1. 在数组中存储hash
my %hash_week_a = ( "Sun" => "Sunday", "Mon" => "Monday", "Tue" => "Tuesday", );
my %hash_week_b = ( "Wed" => "Wednesday", "Thu" => "Thursday", "Fri" => "Friday", "Sat" => "Saturday", ); #注意{}一定要有,否则无法正常赋值于数组!!!
my @arr_week = ({%hash_week_a}, {%hash_week_b}); #遍历Hash数组
for(my $i=0; $i<@arr_week; $i++) {
foreach my $key (keys %{$arr_week[$i]}) {
print "$key => $arr_week[$i]{$key}\n";
}
}
#result: Mon => Monday Tue => Tuesday Sun => Sunday Fri => Friday Wed => Wednesday Thu => Thursday Sat => Saturday