in reply to Confusing regex match.

My best guess is that the file contains CRLF line termination, and you're running the perl script on a non-CRLF system (unix, linux, macosx). Observe:
perl -e 'print "pl\r\n"' > /tmp/j.txt perl -e 'open(I,"/tmp/j.txt");$/=undef;$_=<I>; print ". matches CR on $^O\n" if(/p.{2,6})'
For me, that yields ". matches CR on darwin".