[Chicago-talk] LWP can't wait for data

Randal L. Schwartz merlyn at stonehenge.com
Tue Feb 28 17:35:32 PST 2012

>>>>> "JJacobus" == JJacobus  <JJacobus at PonyX.com> writes:

JJacobus> Code snippet:
JJacobus> 	$file_url = 'http://data.example.com/Feed.ashx?username=user&password=pass';
JJacobus> 	my $ua = LWP::UserAgent->new;
JJacobus> 	$ua->timeout(300);
JJacobus> 	my $response = $ua->get($file_url);
JJacobus> 	if ($response->is_success)
JJacobus> 	{ 	print "Response was successful\n";
JJacobus> 		... (good)
JJacobus> 	} else { print "Response was not successful\n"; }
JJacobus> 		...(bad) ...

dump the response in the fail branch:

  print $response->as_string

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

More information about the Chicago-talk mailing list