[tpm] Another Regex question

Chris Jones cj at enersave.ca
Tue Oct 23 07:57:18 PDT 2012

Thank you so much for all your help!
I must make a donation to something in compensation for making my 
work life more productive!

I have a bunch of files to delete in sub-directories.

I only want to keep files with the following pattern:

Any other files should be deleted.  Unfortunately my simple search 
did not separate files such as:
SimFile-Name.r2 - Baseline Design.inp

use strict;
use File::Find;


my $start=("./");

finddepth (\&wanted, $start);
sub wanted {
         my $file = $_;
         #mod, eux, cfg test for each one
         if (( -f $file) && ( $file =~ /\.(inp|pd2)$/ ))
                 print "File $file, keep\n";
                         print "File $file, delete\n";

Christopher Jones, P.Eng.
Suite 1801, 1 Yonge Street
Toronto, ON M5E1W7
Tel. 416-203-7465
Fax. 416-946-1005
email cj at enersave.ca

More information about the toronto-pm mailing list