in reply to simple regex match question
* and . have special meaning within regexes. If the string you're passing as a pattern into your regular expression contains an asterisk, that is going to be interpreted as a quantifier. And '.' is interpreted to mean "any character except newline".
You could probably do it like this:
if ( $file =~ m/\Q$file_pattern\E$/ ) { # .......
Also note the '$' which anchors the match to the righthand side of the filename. Otherwise, you might find yourself matching "filename.txt.xml" on accident.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simple regex match question
by Anonymous Monk on Nov 13, 2006 at 06:07 UTC | |
by davido (Cardinal) on Nov 13, 2006 at 06:11 UTC |