www.perl.com
Perl Programming
Object-oriented LWP
  • More control over the process
  • Requests and responses are represented by objects
    • $ua->get($url) -- get a URL and return an HTTP::Response object
    • $ua->head($url) -- head a URL and return an HTTP::Response object
    • $ua->post($url, \%form) -- post to a URL and return an HTTP::Response object
    • $ua->mirror($url, $file) -- get a URL if it has changed and return an HTTP::Response object
    • $ua->request($request) -- execute an HTTP::Request object
    • perldoc LWP::UserAgent for complete description

        use LWP::UserAgent;
        my $ua = new LWP::UserAgent;
	$ua->timeout(10);
	my $response = $ua->get("http://web.mit.edu/");
	if ($response->is_success) {
	  print "web.mit.edu was last modified at ", scalar(localtime($response->last_modified)), "\n";
	} else {
	  die "Couldn't fetch web.mit.edu.";
	}
      
http://stuff.mit.edu/iap/perl/