Having said that and realizing the caffiene/sleep ratio is far too high, lets have some fun. Can we do this in one line? Why, yes!
which will not call unlink on directories and return a list of the files deleted. It does assume that you have done a depth-first walk to generate the file names though. Now, this is useful, but I could generate the "expected to be blown away" list easier. What I would be interested in is the files that didn't get blown away.@dead = grep { ! defined( $keep{$_} ) && ( -d $file ? rmdir : unlink ) && $_ } @files;
Well this is cute, but why couldn't we blow the file away?@dead = grep { ! defined( $keep{$_} ) && ( ( -d $file ? rmdir : unlink ) || $_ ) } @files;
On second thought, follow lhoward's suggestion - this code is dangerous and will likely get you cursed by anybody having to maintain it.@dead = grep { ! defined( $keep{$_} ) && ( ( -d $file ? rmdir : unlink ) || "$_:$!" ) } @files;
Mik Firestone ( perlus bigotus maximus )
In reply to RE: Re: Hard disc pruner
by mikfire
in thread Hard disc pruner
by dmtelf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |