I just installed perl 5.8.8 on a xp pro box and having issues with the
getopts. If execute the script directly on the command line, the flags
in the script do not get set. If I run the script by prefixing the
per.exe, getopts works correctly. Any pointers how can I resolve this?
The script is pasted below. It dies on the very first die statement.
#!c:/per/bin/perl
use Getopt::Std;
getopts('a:c:');
die "Getopt not working opt a not set\n" if ( ! defined($opt_a) );
die "Getopt not working opt c not set\n" if ( ! defined($opt_c) );
print "$opt_a is the value for opt a\n";
print "$opt_c is the value for opt c\n";
C:\>type a.pl
#!c:\perl\bin\perl
use Getopt::Std;
getopts('a:s:');
die "Error with getopt\n" if ( ! defined($opt_a) );
print "$opt_a\n" if ( defined ( $opt_a ) );
print "$opt_s\n" if ( defined ( $opt_s ) );
C:\>perl a.pl -atest -stest
test
test
C:\>a.pl -atest -stest
Error with getopt
I'm guessing this is the same problem as was posted here a couple times
since January. It is not a matter of Getopt::Std having a problem, but
rather the command line arguments themselves not being passed to your
perl script.
If I'm right, you need to fix your file associations in Windows.
Please see the following thread to see if the solution there fixes your
issue:
http://groups.google.com/group/perl.beginners/browse_frm/thread/694dc8137f0264f8/7e6502ee06e5a7c5?q=windows+command+line&rnum=18#7e6502ee06e5a7c5
Paul Lalli