Alan, This worked for me! Thanks, Siegfried
#!c:/Perl/bin/Perl.exe # Begin commands to execute this file using Perl with bash # perl test-proxy.pl # End commands to execute this file using Perl with bash package test; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(PopulateSummaries); # Symbols to be exported by default our @EXPORT_OK = qw(); # Symbols to exported by request our $VERSION = 0.1; use strict; use warnings; use LWP; use HTTP::Cookies; use HTML::Parser; use HTTP::Request::Common; use URI; use Date::Manip; use dbPersist; use strict; use LWP::UserAgent; my $content; my $ua = new LWP::UserAgent; # Various enhancement possibilities: # $ua->max_size(100000); # 100k byte limit # $ua->timeout(3); # 3 sec timeout is default $ua->proxy(['http'], 'http://proxy.mycorp.com/'); # set proxy # $ua->env_proxy() # load proxy info from environment variables # $ua->no_proxy('localhost', 'mycorp.com'); # No proxy for local machines $ua->agent("Mozilla/6.0"); # Or something equally mysterious my $req = new HTTP::Request GET => 'http://www.mycorp.com/'; my $res = $ua->request($req); if ($res->is_success) { $content= $res->content; print $content; } else { die "Could not get content"; } -----Original Message----- From: Alan_C [mailto:[EMAIL PROTECTED] Sent: Saturday, April 15, 2006 1:01 AM To: beginners@perl.org Subject: Re: How to use proxy with LWP? On Friday 14 April 2006 23:24, Alan_C wrote: > On Friday 14 April 2006 14:36, siegfried wrote: [ . . ] > > How do I modify the above fragment so I can conditionally use a proxy? http://www.google.com/search?q=perl+lwp+proxy&start=0&ie=utf-8&oe=utf-8&clie nt=firefox-a&rls=org.mozilla:en-US:official http://tomacorp.com/perl/lwp.html http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod#PROXIES http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP/UserAgent.pm#Proxy_at tributes I forgot until now -- but LWP::UserAgent::ProxyAny I'm guessing is a class underneath LWP::UserAgent Thus, (how they are) as to some of the examples as/like at above url(s). print "N \n"; # $ua->no_proxy(qw(no se fi)); # (I guess) } else { print "Y \n"; # change ftp to http for http (I guess) # $ua->proxy(ftp => 'http://proxy.myorg.com'); } -- Alan. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>