I'm working on text files with Windows line terminators (\r\n
), on Linux with Perl v5.30.
Something that I don't understand is why, with these text files, capturing groups don't match characters, while the regular expression matches.
Example:
$ echo $'Line1\r\nLine2\n' | perl -ne 'print /(.*)/'
Line2
$ echo $'Line1\r\nLine2\n' | perl -ne '/(.*)/ && print "match\n"'
match
match
match
Nothing from the first line is captured, but all the (three) lines are matched.
Why is it so?