#!/usr/bin/perl -w # baseline-LWP.pl use strict; use LWP::UserAgent; # Create a user agent object my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1"); # Get a URL my $url = shift or die "Need URL"; # Create a request my $req = HTTP::Request->new(GET => $url); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }