Sorry, when I copied the code, my screen wrap messed it up. The code should be:


use LWP::UserAgent;

my $ua = LWP::UserAgent->new(
env_proxy => 1,
keep_alive => 1,
timeout => 30,
agent => 'Mozilla/4.0 (compatible; MSIE 5.21; Mac_PowerPC)',
);

$request = HTTP::Request->new('HEAD',"http://www.apache.org";);
$r = $ua->request($request);
$res = $r->headers->server;
print "$res\n";

...OR to get just the HTML source:

$request = HTTP::Request->new('GET',"http://www.apache.org";);
$r = $ua->request($request);
$res = $r->content;
print "$res\n";

-john von essen

On Saturday, February 8, 2003, at 11:48 AM, Nigel Horne wrote:

On Thursday 06 Feb 2003 7:12 pm, John Von Essen wrote:
#!/usr/bin/perl

use LWP::UserAgent;

my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout =>
30, ag$
[snip]

On my system the output is:

syntax error at /home/njh/bin/server line 7, near ");"
Execution of /home/njh/bin/server aborted due to compilation errors.

-Nigel



Reply via email to