There's more than one way to do things | |
PerlMonks |
Unable to match newlineby robinson (Novice) |
on Nov 17, 2015 at 19:09 UTC ( [id://1147947]=perlquestion: print w/replies, xml ) | Need Help?? |
robinson has asked for the wisdom of the Perl Monks concerning the following question: Hello: For a long time I was using grep with the option "-P" to turn on Perl pattern matching to detect if a file contained a given text. The pattern could be very simple or very complicated so I needed regular expressions. Then I ran into some trouble where grep would complain that "PCRE's backtracking limit is exceeded". I could never find a working solution so I decided that instead of using grep to emulate Perl, I could just use a Perl one-liner and cut the middle man. Now I'm running into some problems with Perl because for some reason it is refusing to match some files even thought everything seems correct and if I take the same expression and use it with 'grep -P', it has no trouble finding the match. Here is a portion of my Perl one-liner (on linux). If there was a match, it would exit with code 0 (trying to emulate grep's behavior) Here is a partial content of the file "filename.txt": Here is the same partial content in hex (because there are some not visible chars there): For the life of me I can not find a way to make Perl to match that. If I use the same expression with Grep, it has no problem matching it:
What am I missing? I would really appreciate your help as every Regex program and editor and debugger says the regex is correct and like I said, grep has no problem at all matching it.
Back to
Seekers of Perl Wisdom
|
|