I am trying to match a pattern over multiple lines. I would like to ensure the line I'm looking for ends in \r\n and that there is specific text that comes after it at some point. I already tried in grep but it doesn't work without the -P switch which some versions don't have. So now I'm trying in perl.
I can't figure out why this doesn't work:
echo -e -n "ab\r\ncd" | perl -w -e $'binmode STDIN;undef $/;$_ = <>;if(/ab\r\ncd/){print "test"}'
I enabled slurp mode globally (undef $/;) which is sloppy but fine for this (I'll certainly take any better ideas). If I just do a print and pipe it to od I can see that $_ holds the correct bytes. The regex should match those same bytes but doesn't work for some reason. I can match ab\r but not ab\r\n etc.
$afterperl -w -efor?$is why your code was not working.