Getopts problem



Hi,

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

.



Relevant Pages

  • [KSH88] passing args to getopts when getopts is embedded in functions
    ... script by getopts while getopts is nested two functions deep. ... while getopts d:t: FOO ... things like calling ParseArgs, and main, like so, main "$*" ParseArgs ...
    (comp.unix.shell)
  • Re: getopts AGAIN!!!
    ... echo "Value of OPTARG is: ... make apparent why getopts and your script reports no error)... ... myscript -x -3.14 ...
    (comp.unix.shell)
  • Question regarding getopts.
    ... script with getopts and have run into a problem. ... myscript takes arguments with options, but the last argument will be a ... Now....I have no trouble using getopts to process ... the username? ...
    (comp.unix.shell)
  • Re: Using ":" as argument
    ... >>shorter one has a syntax error, ... >>The following lines are the portion of the script that contain the ... while getopts:roe options ... Your script only validates the range of the integer parameters when no ...
    (comp.unix.shell)
  • Re: Watch/view shell script lines during execution?
    ... long ago in a galaxy far away I was fluent in DCL under ... > would cause each line of the script to be output to STDOUT during ... And include a getopts such as: ...
    (comp.unix.shell)