[EMAIL PROTECTED] wrote:
Hi

Hello,

I would like to compare two files by comparing the files dates.
If one file shows
ls -la May 12 2003 filename
and the other name shows the same date they are OK for me (I'm not
interested in the time part only the date of the file)
But if the dates are not the same I would like to copy one of the
files.
How do I do this in Perl?
if (file1 "not equal in date" file2) {
 cp file 1 someplace
}

( my $date1 = localtime +( stat 'file1' )[ 9 ] ) =~ s/\d+:\d+:\d+//;
( my $date2 = localtime +( stat 'file2' )[ 9 ] ) =~ s/\d+:\d+:\d+//;

if ( $date1 ne $date2 ) {
    # copy 'file1', ...
    }



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to