perl脚本提示“Getopts”aborted due to compilation errors.

    科技2022-07-16  123

    test.pl内容如下:

    #!/usr/bin/perl require 'getopts.pl'; do Getopts('rs:o:di:he:d'); ...

    运行perl脚本时,遇到下面的Error:

    syntax error at ./test.pl line 63, near "do Getopts(" Execution of ./test.pl aborted due to compilation errors.

    提示Error原因如下: 这个错误是因为perl从5.16开始,移除了getopts.pl (http://search.cpan.org/~rjbs/perl5.16.0/pod/perldelta.pod#Removed_Modules_and_Pragmata)

    有两种方法可用: (1)把这些被移除的模块加回去(没有试过) 安装Perl4::CoreLibs这个模块 注:仅仅是将getopts.pl这一个文件添加回去,是不管用的。

    (2)修改perl调用方法(测试可行)

    #!/usr/bin/perl #require 'getopts.pl'; #do Getopts('rs:o:di:he:d'); use Getopt::Std; getopts('rs:o:di:he:d'); ...
    Processed: 0.010, SQL: 8