[英]Subroutine redefined errors with 'do' calling another Perl script
[英]Odd subroutine compilation errors in Perl script
為了比較,分別將兩段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-
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.