在 Windows 7 中使用 ActivePerl @ARGV 为空 [英] @ARGV is empty using ActivePerl in Windows 7
问题描述
我有以下 Perl 脚本.我正在尝试使用 ActivePerl 在 Windows 7 中运行它:
I have the following Perl script. I am trying to run it in Windows 7 using ActivePerl:
#!c:Perl64inperl.exe -w
use strict;
my $mp3splt_exe = 'c:Program Files (x86)mp3spltmp3splt.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
";
(如您所见,我正在尝试为 mp3splt 创建一个包装器 :-))
(as you can see, I am trying to create a wrapper for mp3splt :-) )
当我这样运行它时:
C:Program Files (x86)mp3splt>run_mp3splt.pl a
C:Program Files (x86)mp3splt>run_mp3splt.pl a
我明白了:
Use of uninitialized value $filename in concatenation (.) or string at C:Program Files (x86)mp3splt
un_mp3splt.pl line 12.
c:Program Files (x86)mp3spltmp3splt.exe -o "@n @f" -g "r%[@o @N]" -f -t 6.0
所以,首先,当我 print @ARGV
时,什么都没有打印出来,其次,当我分配 $filename = $ARGV[0]
时,$filename
是 undef
,所以我收到警告.
So, first of all, when I print @ARGV
, nothing gets printed, and second of all, when I assign $filename = $ARGV[0]
, $filename
is undef
, so I get the warning.
那么……我做错了什么?为什么没有将命令行参数传递给脚本?
So... what am I doing wrong? Why isn't the commandline parameter being passed to the script?
推荐答案
我很确定 Windows 7 不理解 shebang 行.如果你用 perl run_mp3splt.pl a
运行它会发生什么?
I'm pretty sure Windows 7 doesn't understand the shebang line. What happens if you run this with perl run_mp3splt.pl a
?
这篇关于在 Windows 7 中使用 ActivePerl @ARGV 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!