in reply to Deleting old files from directory

Just need to know if this is efficient or if there is a better way of doing this.

It is more efficient to stat only once, ie

grep {-f $_ and 10 < -M _ }
stat, -X

Replies are listed 'Best First'.
Re^2: Deleting old files from directory
by Anonymous Monk on Sep 27, 2011 at 20:03 UTC
    this is what you mean?
    foreach (grep {-f $_ and 10 < -M _ } @files) { print "\n Deleting::: $_\n"; unlink $_; }

      Almost

      Simply replace EXISTING grep block with mine, no need to change anything else