【问题标题】:perl Getopt::Long output issueperl Getopt::Long 输出问题
【发布时间】:2016-02-08 17:15:08
【问题描述】:

测试 Getopt::Long perl,当使用参数执行时,选项打印命令输出是 1,而不是提供的参数。

这是代码..找不到这里缺少的东西。

#!c:\Perl\bin
use Getopt::Long;

(@ARGV) or die "$0 --file <file name> --cb <CBEntry>";

GetOptions( "file" => \$file,
            "cb" => \$cb) or die "$0 --file <file name> --cb <CBEntry> :$! \n";

#print @ARGV;
print $file;
print $cb;

【问题讨论】:

标签: perl options getopt-long


【解决方案1】:

以下表示无参数选项:

"file" => \$file

要接受字符串参数,请使用以下命令:

"file=s" => \$file

Option Specifications

【讨论】:

  • 谢谢..这有帮助..认为这是一个值分配而不是数据类型。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
  • 2010-10-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多