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

Time conflict using utime

Student of Perl
February 12, 2002 16:29
Time conflict using utime
Message ID:

I have used Net::FTP for ftp coding 
in my script.

my problem is related to file modification
time. I use


#get remote_file to local disk

#and then set its date to that of remote file's date
utime $remote_date,$remote_date,$remote_file 

please note that in the 2nd statement $remote_file is now stored as locally hence here(in 2nd statement)the name $remote_file actually refers to the downloaded copy of the remote file.

So my purpose is to download the file and set its
modification time to that of remote file. The problem
is that taken the complete epoch number that
$ftp->mdtm() returns ; the last digit seems to be
increased by 1 in local epoch number ; this I came to
know when I checked the number returned by 
(stat $filename)[9]  function. So why there is difference
of 1 number between these 2 digits? I am calling
utime function after $ftp->get() function ; so that
means I change modification date after that file
has been created locally(or say downloaded). I want
the dates to be exactly same for local and remote
copy. I would have programmatically increased the
number by 1 ; but that assumption I dont think is safe.
So how to overcome this problem?

-Jim Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About