chapter6.1.pl
#!/usr/bin/perl -w
my %family = (
"fred" => "flintstone",
"barney" => "rubble",
"wilma" => "jack"
);
print"Please Input The Name\n";
$famliy_name = <STDIN>;
$famliy_result = $family{$famliy_name};
print "The famliy of $famliy_name is $famliy_result\n";
chapter6.2.pl
#!/usr/bin/perl -w
my %word_num;
my $word;
print"Please Input Word To Calclute The Num,End of Ctrl + D\n";
while(chomp($word = <STDIN>)) {
if(exists $word_num{$word}){
$word_num{$word} += 1;
}
else {
$word_num{$word} = 1;
}
}
while(($key,$value) = each %word_num){
print"$key => $value\n";
}