# Methods to compare file ages - as in the last modification date.
# Given a list of files as arrays, scalars or
# pointers to arrays, mostRecent() will return the most recent file. If used in
# array context will return the file date ( in yyyymmdd form).
use Files::Compare;
$file = Files::mostRecent( @files, \@files2, 'file3', ...);
($file,$date) = Files::mostRecent(  Files::list( $mask, 'path1'));
print "Most recent file is $file, modified last at $date\n";
 
# The compare method can be used to sort a list of files by date or to
# see the time difference between files.
print "$left is newer than $right" if Files::compare( $left, $right) > 0;
print "$left is older than $right" if Files::compare( $left, $right) < 0;
print "$left is the same age as $right" if Files::compare( $left, $right) == 0;
 
my $seconds = Files::compare( $left, $right);
print "$left is $seconds seconds newer than $right" if  $seconds > 0;
$seconds = abs( $seconds);
print "$left is $seconds seconds older than $right" if  $seconds > 0;
 
# Lastly there is a convenience method outOfDate() that only returns true if
# one of a list of files has a more recent date than the first.
recreate( $htmlFile) if Files::outOfDate( $outOfDate,  Files::list( $mask, 'path1'));