use Data::Dumper;
#my %fruit_color = ("apple", "red", "banana", "yellow");
my %fruit_color = (
apple => red, #note : 带不带“”都无所谓
banana => yellow,
);
print Dumper(%fruit_color);
#print $fruit_color{apple},"/n";
#print $fruit_color{"banana"};
my @fruits = keys %fruit_color;
print $#fruits,"/n";
for ( my $i=0; $i<=$#fruits; ++$i ){
my $key=$fruits[$i];
print $i,"[",$key,"]",$fruit_color{$key},"/n"; #{} not []
}
my @colors = values %fruit_color;
print $#colors,"/n";
for ( my $i=0; $i<=$#colors; ++$i ){
my $key=$colors[$i];
print $i,"[",$key,"]/n"; #{} not []
}