in reply to Getting commandline params
There is a difference between the getopt() method and the getopts() method which is the boolean one you want. Read the docs for details. With getopt() if you supply the command line argument -p12 then $opt_p = '12'. If you go -p then you just get an undefined value. With getopts() if you go -p you get then $opt_p = '1' which is what I imagine you want. If you don't supply the -p command line arg then you get an undefined value. This is presumably fixed version. 1 lousy 's' is all that was missing!
cheersuse strict; use warnings; use Getopt::Std; use LWP::UserAgent; our($opt_p); getopts('p'); # getopts() not getopt() print "\nThe value in \$opt_p is "; print defined($opt_p) ? "'$opt_p'" : "undefined"; my $agent = LWP::UserAgent->new(); ($opt_p == 1 ? $agent->env_proxy() : $agent->proxy(http => $opt_p)) if + (defined($opt_p));
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|