Help with perl script to compare dates of 2 files

Argo

Lifer
Apr 8, 2000
10,045
0
0
Can somebody help me out with a perl script that would compare dates of 2 files. I know nothing about perl. Basically I need to do something like:

if (file1 is newer than file2) {
exit;
}
 

Mitzi

Diamond Member
Aug 22, 2001
3,775
1
76
Depends what you mean by 'date' - modified date, creation date etc etc.

Example:

$name1 = "myfile.dat";
$name2 = "myotherfile.dat";

Modification age in days:
if (-M $name1 > $name2)

Access age in days:
if (-A $name1 > $name2)