简体   繁体   中英

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).

只需解决您的语法错误:用$ fileB替换“ FileB”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM