dpmott has asked for the wisdom of the Perl Monks concerning the following question:
my script locks up.my $doc = get URL;
where URL is the same as what is in the script. That works fine, presumably because GET.pl uses LWP::UserAgent.perl -S GET URL
#!perl # What's Wrong with LWP::Simple::get ? use strict; use LWP::UserAgent; use LWP::Simple; use constant URL => 'http://www.google.com'; main(); exit(0); sub main { print "Fetching '" . URL . "' with LWP::UserAgent\n"; my $ua = LWP::UserAgent->new(); my $response = $ua->get(URL); if ( $response->is_success ) { my $len = length($response->content); print "Retrieved $len bytes\n"; } else { my $code = $response->code; print "Failed to retrieve URL: $code\n"; } print "Fetching '" . URL . "' with LWP::Simple\n"; my $content = LWP::Simple::get( URL ); if ( $content ) { my $len = length($content); print "Retrieved $len bytes\n"; } else { print "Failed to retrieve URL\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why would LWP::Simple::get stop working?
by tlm (Prior) on Jun 20, 2005 at 19:32 UTC | |
by dpmott (Scribe) on Jun 20, 2005 at 20:05 UTC | |
|
Re: Why would LWP::Simple::get stop working?
by ikegami (Patriarch) on Jun 20, 2005 at 19:22 UTC | |
by dpmott (Scribe) on Jun 20, 2005 at 19:26 UTC | |
by ikegami (Patriarch) on Jun 20, 2005 at 19:48 UTC | |
by dpmott (Scribe) on Jun 20, 2005 at 20:08 UTC | |
by ikegami (Patriarch) on Jun 20, 2005 at 20:39 UTC | |
|
Re: Why would LWP::Simple::get stop working?
by Steve_p (Priest) on Jun 20, 2005 at 19:11 UTC | |
by dpmott (Scribe) on Jun 20, 2005 at 19:14 UTC |