I don't generaly use the Getopt module. I parse stuff myself to get the behaviour I want. You get the command line args in @ARGV. Here is an example with minimal flexibility and error checking. It takes a -p flag and and optional proxy arg.
C:\>type test.pl my ($switch, $proxy) = @ARGV; $switch = ($switch eq '-p') ? 1 : 0; $proxy = defined $proxy ? $proxy : 'undef'; print "Switch is '$switch', and proxy is '$proxy'\n"; C:\>perl test.pl Switch is '0', and proxy is 'undef' C:\>perl test.pl -p Switch is '1', and proxy is 'undef' C:\>perl test.pl -p http://proxy.foo.com/proxy.pac Switch is '1', and proxy is 'http://proxy.foo.com/proxy.pac' C:\>perl test.pl http://proxy.foo.com/proxy.pac Switch is '0', and proxy is 'undef' C:\>
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Re: Re: Getting commandline params
by tachyon
in thread Getting commandline params
by Amoe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |