Question : LWP Simple useragent

I have a site where users can submit url's of files for download
This is then included into a searchable database.

Currently i check the url is valid using the LWP::Simple module
I can not use the HTTP modules (they are not available on the host i use)

($content_type, $document_length, $modified_time, $expires, $server) = head("http://url");

When the url is invalid the header information is blank
Is this a good way to check or is there another method?

also when using the above method the log files of the server being accessed show the useragent as "LWP::Simple/5.68"
Can i change the useragent ?

Answer : LWP Simple useragent

Sample code, change value in :

#!/usr/bin/perl
use LWP::UserAgent;

$url='http://www.experts-exchange.com';

$ua = LWP::UserAgent->new;
$ua->agent("Myagent/6.0");
$req = HTTP::Request->new(HEAD => $url);

# send request
 $res = $ua->request($req);

 # check the outcome
 if ($res->is_success) {
    print "URL is ok";
 } else {
    print "URL not ok, error: " . $res->status_line . "\n";
 }
 
Random Solutions  
 
programming4us programming4us