in reply to Can't match my regex
Perl does a good job of hiding this \r\n ugliness from the user. In your working string with single quotes, you are actually getting a backslash then letter r, etc.
my ($version) = $line =~ m/^Version:\s(\d+)\\r\\n$/; does match 'Version: 0\r\n'. Things change if you use double quotes.
I'm not quite sure, but I suspect that your test case string isn't doing what you expect. When Perl does a normal sort of a read, it will get rid of the \r (return) character. There is no need for you to do that yourself (except cases where you are reading binary bytes, etc).
Anyway I don't think your \r test case is a good one as you will never see that \r. The $end of string anchor will work fine on Windows or Unix.
|
|---|