Yeoh Yiu wrote: >>From the new PERL LWP book: > The first example I tried doesn't work. > > Should I > use LWP; > or > use LWP::UserAgent; > ? > The both failed. > > ################################## > # ex 1-2, p11; > use strict; > use LWP; > > my $url = "http://use.perl.org/"; > my $browser = LWP::UserAgent->new(); > my $response = $browser->get($url); > print $response->header("Server"), "\n"; > > > H:\perl>perl -w up.pl > Can't locate object method "get" via package "LWP::UserAgent" (perhaps > you forgot to load "LWP::UserAgent"?) > at up.pl line 8. > > H:\perl> > > H:\perl>perl -MLWP -le "print(LWP->VERSION)" > 5.51
This should do if you just want the server: use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $url = "http://use.perl.org/"; my $req = new HTTP::Request 'HEAD', $url or die "new Request: $!"; my $res = $ua->request($req) or die "request: $!"; if ($res->is_success) { print "Server=", $res->header("Server"), "\n"; } else { print "HEAD request failed to $url\n"; } __END__ -- ,-/- __ _ _ $Bill Luebkert ICQ=162126130 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Web mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs