How to find few minutes older files in perl

I only want to process files which are last modified 10 minutes ago. I am trying to achieve it like this.

for my $file (<${dir}/*csv>_) { 
    if ( -M $file < .0069 ) {
        next;
        }
    else {
         code ...
          }
    } 

.0069 days have been counted for 10 minutes (10/ (24*60)). Now files present in the directory which are older than 1 day are identified correctly but any file which is less than 1 day older is recognized incorrectly. for example if file is 23 hours older it is getting processed in if block rather than else.
I guess ‘-M $file’ converting its value to integer (i.e. 0 in this case). Can anyone help here? Thanks


Source: unix

Leave a Reply