in reply to Re: Delete old files
in thread Delete old files

Looked at this and it still gives me any files in the directory:
... my @file_list; while (my $file = readdir DIR) { next if $file=~/^\./; push @file_list, $file; } closedir DIR; for my $files (@file_list) { my @stats = stat($files); if ($now-$stats[9] > $age) { # files older than 7 days print "$files\n"; } } ...

Replies are listed 'Best First'.
Re^3: Delete old files
by Corion (Patriarch) on Mar 17, 2014 at 19:30 UTC

    How did you change the construction of the entries in @file_list after reading the second paragraph of readdir?

    Also, why not use the following instead of the loop?

    my @file_list= glob("$old/*");
      Sure it can still be like that:
      ... # get all ttct files from here my @file_list= glob("old/*.txt"); for my $files (@file_list) { if ($now-(stat $files)[9] > $age) { # file older than 7 days print "$files\n"; } }

      Still doesnt work.

        Perhaps if you read the linked documentation you could see what's wrong.

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.