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

Sorry, should've included it in the post - I'm using the script on Win platform, so no shell option for me...

Is it not possible to say something along the lines of

if (-x /se\d{4}ab/) {unlink _;}

Of course the one I just wrote doesn't work but I mean, the general idea of combining it like this... I realize my ideas might look silly but my eyes still glaze over when I see regexps...

--------------------------------
An idea is not responsible for the people who believe in it...

Replies are listed 'Best First'.
Re^3: Delete files matching pattern
by radiantmatrix (Parson) on May 10, 2005 at 16:17 UTC

    You're not far off, actually:

    foreach (@files) { unlink $_ if (/se\d{4}ab/i && -x) }
    would work if @files contains the list of all the files you want to check. A quick note -- others picked up on it in code, but didn't mention explicitly -- the i at the end of the regex will match in a case-insensitive manner, which is faster than invoking the lc() on each potential filename as you do in your original code.

    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.