develooper Front page | perl.beginners | Postings from February 2002

Re: time setting for local and remote files

Thread Previous
From:
John W. Krahn
Date:
February 12, 2002 14:04
Subject:
Re: time setting for local and remote files
Message ID:
3C69919B.9B3BF960@acm.org
Student Of Perl wrote:
> 
> use Net::FTP;
> 
> use constant HOST=>'ftp.somexample.com';
> $ftp=Net::FTP->new(HOST) or die "connection error";
> $ftp->login('anonymous') or die $ftp->message;
> $ftp->binary or die $ftp->message;
> $ftp->get("sample.txt") or die $ftp->message;
> $ftp->quit();
> 
> I have the above script created.The site and file names
> I have taken as an arbitrary examples. Basically I have
> 2 questions.
> 
> How do I get date and time of the remote ftp file?

my $remote_file_date = $ftp->mdtm( $remote_file );


> How do I get date and time of local file?

my $local_file_date = (stat $local_file)[9];


> (This is not related with the above code directly;
> basically I want to compare date and time of local
> and remote files)
> 
> And how to set date and time for local file?
> I would like to set any date for a local file.

my $today = time;
utime $today, $today, $local_file;



John
-- 
use Perl;
program
fulfillment

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About