Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by GotToBTru (Prior)
on Jul 16, 2015 at 14:56 UTC ( #1135030=note: print w/replies, xml ) Need Help??


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
  • Comment on Re: How to handle metacharacters in input file for Perl one-liner code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2021-10-22 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?