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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-01-17 09:22 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (198 votes). Check out past polls.