Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by kennethk (Monsignor)
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.


Comment on Re: how to check whether a particular word exists in filename
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (16)
As of 2014-07-22 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (122 votes), past polls