roho has asked for the wisdom of the Perl Monks concerning the following question:

I am running ActiveState Perl 5.8.7 on Windows XP. I am using Getopt::Std for command line options. When I execute the program implicitly (sample.pl -h) the command line option is not recognized. When I execute the program explicitly (perl sample.pl -h) the command line option is recognized. What must I do to have the command line option recognized when executing the program implicitly? Following is a sample which shows the problem. TIA.
#!/usr/bin/perl -w use strict; use vars qw($opt_h); use Getopt::Std; getopts("hiy:"); if(defined $opt_h) { print "\n"; print " Usage: sample.pl [options]\n"; print "Options:\n"; print " -h display help.\n"; exit; }

"Its not how hard you work, its how much you get done."

Replies are listed 'Best First'.
Re: Command Line Options - Perl on Win32
by Corion (Patriarch) on Nov 25, 2006 at 18:23 UTC

    See Re: Can't pass parameters in Win32 Perl Scripts. Also, before trying to fix it, have a look at the association before and after, as pKai suggests, so maybe we can nail it down to what exactly is the symptom.

    Especially interesting would be the output of ftype perl (or whatever name .pl scripts are linked to.

      Sorry to trouble you all. I just checked the registry entry "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Perl\shell\Open\command" and disovered the execution line contained '-s', which negates Getopt processing. Thanks also, Corion, for the page reference.

      "Its not how hard you work, its how much you get done."