LWP::Useragent request

ldsdates

New Member
Messages
6
Reaction score
0
Points
0
Has anyone gotten a useragent request to work? My code shown below allows me to make a web request and puts the response in a variable. It works elsewhere, but when I attempt to use it here it never completes the get($request)

use LWP::Simple qw($ua get);
my $ua = new LWP::UserAgent;
my $request = $_[0];
$ua->timeout(30);
$response = get($request);
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
That's not quite enough to test. Is the posted fragment part of a function, or is it top-level code? Are you sure $_[0] holds a URL?
 

ldsdates

New Member
Messages
6
Reaction score
0
Points
0
This is the whole thing, wrapped in a sub. - you are right $_[0] is the url you are attempting to get.

## Usage: $html=&getpage("http://yourwebsite.com/cgi-bin/page.cgi");
sub getpage {
use LWP::Simple qw($ua get);
my $ua = new LWP::UserAgent;
my $request = $_[0];
$ua->timeout(30);
$response = get($request);
return "$response";
}
 
Top