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

Can someone please tell me why this code doesn't print 'Agent proxy is now http://www.proxy.com' when run with the command line perl test.pl -p http://www.proxy.com? It emits a few warnings ("Use of uninitialised value in hash element at C:/Perl/site/lib/LWP/UserAgent.pm line 612") Sorry for the abrupt question, but I'm certain it's something very basic I'm missing here. It's very simple code, and to my mind it should work.
#!/usr/bin/perl -w use strict; use warnings; use Getopt::Std; use LWP::UserAgent; my $agent = LWP::UserAgent->new(); my %switches; getopts('p:', \%switches); if (exists($switches{p})) { if ($switches{p}) { $agent->proxy('http', $switches{p}); } else { $agent->env_proxy(); } } print "Agent proxy is now ".$agent->proxy;


--
my @words = grep({ref} @clever);
sub version { print "I cuss your capitalist pig tendencies bad!\n" }

Replies are listed 'Best First'.
Re: Setting LWP::UserAgent proxy
by projekt21 (Friar) on Sep 26, 2001 at 19:50 UTC

    Try:

    print "Agent proxy is now ".$agent->proxy('http');

    alex pleiner <alex@zeitform.de>
    zeitform Internet Dienste