Gossamer Forum
Home : General : Perl Programming :

"detect" the last modification date

Quote Reply
"detect" the last modification date
I want to make a remote search engine. But there is some problem. What is the perl command to "detect" the last modification date of a remote file???
Quote Reply
Re: "detect" the last modification date In reply to
You need to use LWP and fetch the pages headers. The date is in there. See the LWP::UserAgent documentation for more info.

Cheers,

Alex
Quote Reply
Re: "detect" the last modification date In reply to
Hi,

Alex, do you have one example to get the last modification date of a remote file?



------------------
[]'s

Lucas Saud - #19815087









Quote Reply
Re: "detect" the last modification date In reply to
Sure! How about:

Code:
use LWP::UserAgent;

my $agent = new LWP::UserAgent;
my $req = new HTTP::Request ('GET', 'http://www.sfu.ca');
my $resp = $agent->request ($req);
print "Last Updated: ", scalar localtime $resp->last_modified(), "\n";

Cheers,

Alex
Quote Reply
Re: "detect" the last modification date In reply to
Tanks Alex!

But i have one more question:

You have one exemple to get the size of a remote file?

------------------
[]'s

Lucas Saud - #19815087









Quote Reply
Re: "detect" the last modification date In reply to
THANKS A LOT!!!!!!!

But there's still some problems...
when I use this code:
--------------------------------------------
#!/usr/local/bin/perl

use LWP::UserAgent;
my $agent = new LWP::UserAgent;
my $req = new HTTP::Request ('GET', 'http://members.tripod.com/mp3oricon/');
my $resp = $agent->request ($req);
print "Content-type: text/html\n\n";
print "Last Updated: ", scalar localtime $resp->last_modified(), "\n";
--------------------------------------------
the browser print out "Last Updated: Wed Dec 31 16:00:00 1969"
actually this file is last updated at 1999/6/6 AM 06:05

Also I dont want 'Wed' and '16:00:00' to be showed up, can it be done??



[This message has been edited by jpop (edited June 07, 1999).]

[This message has been edited by jpop (edited June 07, 1999).]