in reply to Re^2: Delete files matching pattern
in thread Delete files matching pattern

First, I didn't say it would be faster, just simpler. I don't know what you mean about being Byzantine and obscure. It's pretty straightforward to me:

use File::Find; find(\&matches_regex, '.'); sub matches_regex { return undef unless (m/.+\.txt$/ && -f); unlink $File::Find::name,"\n"; ## scalar contains full path }

This will find and unlink all TXT files in a tree. Now, that may not be as concise, but I personally found it easier to control and understand than readdir loops. YMMV, I suppose. If performance was the primary goal, I would unequivocally agree that File::Find is probably not what one wants.


The Eightfold Path: 'use warnings;', 'use strict;', 'use diagnostics;', perltidy, CGI or CGI::Simple, try the CPAN first, big modules and small scripts, test first.