in reply to Re: No. files in folder
in thread No. files in folder
Well it's not quite fine, on some OS there is a chance that one could find oneself attempting to delete the current directory and it's parent ('.' and '..'). I would suggest something like:
The only problem using the conditional like that on the unlink line is that it makes it more difficult to test whether the unlink succeeded - I would expand it to a full if block.opendir my $d, $dir; + my @f = sort { -M $b <=> -M $a } map { "$dir/$_" } grep !/^\.{1,2}$/,readdir $d; + unlink @f[-0,1] if @f > 20;
/J\
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: No. files in folder
by blazar (Canon) on Jun 23, 2005 at 10:38 UTC | |
by kaif (Friar) on Jun 23, 2005 at 15:03 UTC |
In Section
Seekers of Perl Wisdom