2.
123 my %vertical_alignment;
124 $vertical_alignment{"subscripting"} = 0;
125 unless($vertical_alignment{"subscripting"}){
126 print "0
";
127 }
128 unless($vertical_alignment{"anonymous"}){
129 print "undef.
";
130 }
124行: 不能对散列中的 元素? 再加 my 关键字, 直接操作就可以
如下,散列中的值需手动定义为undef
1.
6 my %vertical_alignment;
7 $vertical_alignment{"subscripting"} = 0;
8 unless($vertical_alignment{"array_ref"}){
9 print "0
";
10 }
11 printf keys %vertical_alignment;
12 if( exists $vertical_alignment{"array_ref"}){
13 print "
there is a library card for subscripting
";
14 }
15 else{
16 print "
no card.
";
17 }
18 $vertical_alignment{"array_ref"} = undef;
19 printf keys %vertical_alignment;
20 if( exists $vertical_alignment{"array_ref"}){
21 print "
there is a library card for subscripting
";
22 }
23 else{
24 print "a o.
";
25 }
输出:
0
subscripting
no card.
subscripting
there is a library card for subscripting