in reply to Re: File list by date
in thread File list by date

Careful! Checking the description of readdir it says one must either chdir or prepend the $dir if you want to do filetests.
foreach (sort {-M qq($dir/$b) <=> -M qq($dir/$a)} readdir(ROOT)) { print $_, $/; }
for example.

Replies are listed 'Best First'.
Re: Re: Re: File list by date
by nkpgmartin (Sexton) on May 03, 2001 at 18:36 UTC
    Using this method (snax), is there a way to only list files that are one hour old, or two hours old, etc.?
      Nope :)

      For OS ways to do this, the *nix answer is to use find and sort. Perl is definitely a reasonable way to go when you want this kind of response.

      I usually pipe ls -lt through head -N to just see the more recent files, though, and vary N as necessary.

      But then again, I'm lazy :)