in reply to Age of directories again with a specified directory

use strict; use warnings; use File::Spec::Functions qw( catfile ); my $dir = 'F:\\test'; opendir(my $dh, $dir) or die("Can't open directory \"$dir\": $!\n"); my @dirs; while (defined(my $fn = readdir($dh))) { next if $fn eq '.' || $fn eq '..'; my $qfn = catfile($dir, $fn); if (-d $qfn && -M $qfn > 10) { push @dirs, $qfn; } } foreach (@dirs) { print("$_\n"); }

For future reference, wrap your code in <c>...</c> when posting on Perl Monks. That'll handle line breaks and encoding characters that need encoding (like <, [ and &).

Replies are listed 'Best First'.
Re^2: Age of directories again with a specified directory
by dilip_val (Acolyte) on Nov 07, 2007 at 22:08 UTC
    Hi Ikegami, Thanks for the reply , tried the code above but its not printing the @dirs
      I just tested it, and it successfully prints out all directories that haven't been modified in the last 10 days. Or did you want something different?