Epligam
Epligam

Reputation: 783

Compare two files' modification time using Perl

I’m trying to compare the modification time of two files (that are being created on the same machine) using Perl just to know which file is older.

I have tried the –M and stat and for some reason the results are not consistency. This is an example for what I have tried:

if ((stat($FileA))[9] < (stat("FileB"))[9]) {

This line sometimes work, but sometimes the results are just the opposite (the comparison should be at a seconds level and not just day \ hour).

Upvotes: 1

Views: 3323

Answers (1)

gil_mo
gil_mo

Reputation: 625

Simply fix your syntax error: replace "FileB" with $fileB.

Upvotes: 1

Related Questions