Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Command Line Options - Perl on Win32

by roho (Chancellor)
on Nov 25, 2006 at 18:16 UTC ( #586030=perlquestion: print w/replies, xml ) Need Help??

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 (Pope) 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."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://586030]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2020-02-23 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (102 votes). Check out past polls.

    Notices?