Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Reg Expression on file name

by sauoq (Abbot)
on Jan 06, 2003 at 19:28 UTC ( [id://224711]=note: print w/replies, xml ) Need Help??


in reply to Reg Expression on file name

The T* part of that restricts the match to files beginning with "AB DA" followed by 0 or more T's followed by ".doc" and that's probably not what you meant. You are missing a dot. Try /^AB DAT.*\.doc$/i instead. Note that I replace the \s with a literal space. That's because \s will also match a tab or a newline.

I don't know if you really want the /i modifier. That will make the expression case insensitive so it will also match files beginning with "ab dat" or "Ab DaT" and so on.

You might also consider using unless rather than if ... !~ too. I'd write the whole thing as

next unless $file =~ /^AB DAT.*\.doc$/;

By the way, filenames with spaces in them are yucky. If you have control over the filenames, I suggest renaming them and replacing spaces with underscores.

-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-28 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found