neniro has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to find all the *.doc files created (or at least modified) in the last 24 hours. The following snippet works fine unless I use mtime( -1 ) - I got an empty resultset. Is this a Windows-related problem, or am I doing something wrong?
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Date::Calc qw/ Time_to_Date /; use File::Find::Rule; my @files = File::Find::Rule->file() ->name( '*.doc' ) ->mtime( -1 ) ->in( 'D:/Dokumentation/' ); @files = map { { name => $_, #modified => [Time_to_Date((stat($_))[9])], size => (stat($_))[7] } } @files; print Dumper \@files;
neniro

Replies are listed 'Best First'.
Re: Using -mtime in File::Find::Rule seems to fail on Windows
by BrowserUk (Patriarch) on Jul 20, 2004 at 13:58 UTC

    The timestamps return by -M, -C & -A are relative to the start of the program. So to find those less than 24 hours old you need to specify 1, not -1; that would be in the future.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
      Of course I tried this before with the same effect. I tried '-1' because it's the way unix-find finds files modified between the last 24 hours. '1' means exactly 24 hours.

        Sorry. I'm not a F::F::R user. However a quick look at the docs suggests that

        ->mtime( '<= 1 ' )

        should do the trick.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon