Search code examples
perlwindows-7command-line-argumentsactiveperl

@ARGV is empty using ActivePerl in Windows 7


I have the following Perl script. I am trying to run it in Windows 7 using ActivePerl:

#!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";

(as you can see, I am trying to create a wrapper for mp3splt :-) )

When I run it like this:

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

I get this:

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

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?


Solution

  • I'm pretty sure Windows 7 doesn't understand the shebang line. What happens if you run this with perl run_mp3splt.pl a?