perl - @ARGV 在 Windows 7 中使用 ActivePerl 为空

标签 perl windows-7 command-line-arguments activeperl

我有以下 Perl 脚本。我正在尝试使用 ActivePerl 在 Windows 7 中运行它:

#!c:\Perl64\bin\perl.exe -w

use strict;

my $mp3splt_exe = 'c:\Program Files (x86)\mp3splt\mp3splt.exe';

my $mp3splt_args = '-o "@n @f" -g "r%[@o @N]"  -f -t 6.0';

print @ARGV;
my $filename = $ARGV[0];

print "$mp3splt_exe $mp3splt_args $filename\n";

(如您所见,我正在尝试为 mp3splt 创建一个包装器 :-))

当我像这样运行它时:

C:\Program Files (x86)\mp3splt>run_mp3splt.pl a



我明白了:
Use of uninitialized value $filename in concatenation (.) or string at C:\Program Files (x86)\mp3splt\run_mp3splt.pl line 12.
c:\Program Files (x86)\mp3splt\mp3splt.exe -o "@n @f" -g "r%[@o @N]"  -f -t 6.0

所以,首先,当我print @ARGV ,什么都不会打印,其次,当我分配 $filename = $ARGV[0] 时, $filenameundef ,所以我收到警告。

所以……我做错了什么?为什么不将命令行参数传递给脚本?

最佳答案

我很确定 Windows 7 不理解 shebang 行。如果你用 perl run_mp3splt.pl a 运行它会发生什么?

关于perl - @ARGV 在 Windows 7 中使用 ActivePerl 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4234581/

相关文章:

c# - 如何在 WinForms 中强制用户使用管理员帐户

git - --parameter 和 -parameter 有什么区别?

perl - 如何在 Perl 中捕获并重新抛出错误?

c# - 使用c#将文件刻录到CD

regex - 如何在 Perl 正则表达式中替换第 n 次匹配?

.net - PrintDialog.ShowDialog(this) 在 Windows 7 上立即返回 DialogResult.Cancel

mysql - 在 shell 脚本中将 MySQL 命令行中的表名作为参数传递

c++ - 为什么命令行参数的字符串比较不起作用?

perl - 我如何让 Perl::Critic 与 E.P.I.C 和 eclipse 一起工作?

sql - 如何使用 DBIx::Class 增加一列?