2013-04-20 103 views
3

这是由s2p生成的程序的一部分,s2p是构建执行特定sed命令的perl脚本的程序。

# getsARGV: Read another input line into argument (default: $_). 
#   Move on to next input file, and reset EOF flag $isEOF. 
sub getsARGV(;\$){ 
    my $argref = @_ ? shift() : \$_; 
    while($isEOF || ! defined($$argref = <ARG>)){ 
     close(ARG); 
     return 0 unless @ARGV; 
     my $file = shift(@ARGV); 
     open(ARG, "<$file") 
     || die("$0: can't open $file for reading ($!)\n"); 
     $isEOF = 0; 
    } 
    1; 
} 

我在perlsub上找不到任何解释这个子签名的东西。

该代码的工作也很好。

+0

有趣的问题。特别是因为我不知道答案可能是什么。 – JohnB 2013-04-20 04:33:50

+0

http://perldoc.perl.org/perlsub.html#Prototypes – 2013-04-20 04:34:37

回答

2

这是一个prototype。该特定原型迫使解析器只接受用途

getsARGV() 

getsARGV($SCALAR) 

,并让它们被编译为

&getsARGV() 

&getsARGV(\$SCALAR)