Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1042261]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2016-12-11 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (169 votes). Check out past polls.