Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: how to check whether a particular word exists in filename

by kennethk (Abbot)
on Jul 03, 2013 at 19:24 UTC ( #1042261=note: print w/replies, xml ) Need Help??

in reply to how to check whether a particular word exists in filename

There are a myriad of ways to solve this issue, but I read your criterion as 'Ends with .txt but not with A1.txt'. The easiest solution here would be to add an additional test to your set:
if ( ( $file =~ m/^CHECK*/ ) && ( $file =~ m/\.txt$/ ) && ( $file !~ m +/A1\.txt$/ ) ) {

Note that I've added a backslash before your .. If you intend to match literal periods, you need to escape them because period is on of the Metacharacters; it matches anything except a new line.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1042261]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2016-10-25 22:07 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.