Perl:子声明的 arg 列表中的 ;\$ 是什么意思?

标签 perl

这是由 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 上找不到任何解释这个子签名的内容。

该代码也能很好地工作。

最佳答案

这是一个prototype .该特定原型(prototype)强制解析器仅接受用法

getsARGV()

getsARGV($SCALAR)

并使它们被编译为

&getsARGV()

&getsARGV(\$SCALAR)

关于Perl:子声明的 arg 列表中的 ;\$ 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16116572/

相关文章:

Perl 音频文件持续时间

perl - 我如何优雅地从 Perl 中的数组引用创建散列?

perl - Perl 5.18+ 中的哈希合并方法受到哈希顺序随机化的影响吗?

c++ - C++ 中长字符串的 Perl 风格引号

linux - 通过 Perl 脚本设置环境变量

mysql - 有没有办法通过解析文本文件来填写Sharepoint条目?

windows - 如何使用 UAC 提升 Perl 进程

perl - Windows XP 上的 CPAN 问题

perl - 如何将通用参数传递给 Perl 模块?

perl - 有没有人成功地将 jqPlot 图表渲染为服务器端图像(例如使用 node.js)?