use strict; use LWP::UserAgent; use HTTP::Request::Common; print &getHTML('http://www.perlmonks.org'); sub getHTML($) { # one $ means one scalar arg - for us humans my $url = shift; #create a new agent and name it my $ua = new LWP::UserAgent; $ua->agent("Shmozilla/0.1 " . $ua->agent); #create new request my $req = new HTTP::Request GET => $url; #send the and try to get a response my $resp = $ua->request($req); return ($resp->is_success) ? $resp->content : "Error\n"; }