http://qs321.pair.com?node_id=1135030


in reply to How to handle metacharacters in input file for Perl one-liner code

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.

Dum Spiro Spero