Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: How to handle metacharacters in input file for Perl one-liner codeby GotToBTru (Prior) |
on Jul 16, 2015 at 14:56 UTC ( [id://1135030]=note: print w/replies, xml ) | Need Help?? |
The period in your file name is being interpreted as the "match-any-character-except-linefeed" wildcard. That's why you get those matches you aren't expecting. "foo.c" matches "foo.c", but also the "foo_c" in "foo_con.*". Putting the \Q and \E around $file tells the regex interpreter not to make those substitutions. Alternatively, quotemeta will 'escape' any characters that might be interpreted as wildcards.
In Section
Seekers of Perl Wisdom
|
|