为了比较,分别将两段ASCII文本(一个L =长,一个S =短)读入@arrayOne和@arrayTwo。以下子例程&analyse从smart.pl代码获取两个数组引用,但通过perl -c smart.pl检查时抛出错误。不幸的是,我不知道为什么:
68 sub analyse {
69 my $arraysize ; my $arrLref ; my $arrSref ; my $item_L ; my $item_S ; my $value ;
70
71 $arrSref = shift ; $arrLref = shift ;
72 $item_S = shift @{ $arrSref } ;
73 $item_L = shift @{ $arrLref } ;
74
75 $arraysize = $#{ $arrSref } ;
76 while ( $arraysize > 0 ) {
77 $value = ( $item_S cmp $item_L ) ;
78 given ( $value ) {
79 when ( -1 ) {
80 push ( @mergedArray , $item_S ) ;
81 $item_S = shift @{ $arrSref }
82 }
83 when ( 0 ) {
84 push ( @mergedArray , $item_L ) ;
85 $item_S = shift @{ $arrSref } ;
86 $item_L = shift @{ $arrLref }
87 }
88 when ( 1 ) {
89 push ( @mergedArray , $item_L ) ;
90 $item_L = shift @{ $arrLref }
91 }
92 default { &die }
93 }
94 }
95 }
使用以下语句中止编译:
$ perl -c smart.pl
syntax error at smart.pl line 78, near ") {"
syntax error at smart.pl line 83, near ") {"
syntax error at smart.pl line 88, near ") {"
Global symbol "$item_L" requires explicit package name at smart.pl line 89.
Global symbol "$item_L" requires explicit package name at smart.pl line 90.
Global symbol "$arrLref" requires explicit package name at smart.pl line 90.
syntax error at smart.pl line 91, near "}"
smart.pl had compilation errors.
也许其他人有线索?预先感谢–DrP-
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句