1 #! usr/bin/perl -w
2
3 %food = (apple => 'fruit',carrot => 'vegetable');
4 %wang =('s' => 'a',
5 'a' => 'b',
6 'c' => 's');
7
8 $x{'ww'} = 'wangpan';
9 $x{'ss'} = 'apnda';
10
11 print $wang{'a'}."\n";
12 print $food{'apple'}."\n";
13 print $x{'ss'}."\n";
14
15 foreach $result(keys %x)#keys返回哈希的所有关键字
16 {
17 print"$result\n";
18 }
阅读(2045) | 评论(0) | 转发(0) |