[tpm] Another Regex question

Antonio Sun antoniosun at lavabit.com
Tue Oct 23 08:41:09 PDT 2012


>        if (( -f $file) && ( $file =~ /\.(inp|pd2)$/ ))

without much formal requirement definition, try to start with this

        if (( -f $file) && ( $file =~ /^\w+-\w+\.(inp|pd2)$/ ))

On Tue, Oct 23, 2012 at 10:57 AM, Chris Jones <cj at enersave.ca> wrote:

> 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:
> SomeFIle-Name.inp
> SomeFIle-Name.pd2
>
> Any other files should be deleted.  Unfortunately my simple search did not
> separate files such as:
> SomeFIle-Name.r2.inp
> SomeFIle-Name.r2.pd2
> SimFile-Name.r2 - Baseline Design.inp
>
> #!/usr/local/bin/perl
> use strict;
> use File::Find;
>
> $\="\n";
> $,="\n";
>
> 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";
>                 }
>                 else
>                 {
>                         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
>
> ______________________________**_________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/**listinfo/toronto-pm<http://mail.pm.org/mailman/listinfo/toronto-pm>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20121023/34039bf8/attachment.html>


More information about the toronto-pm mailing list