I'm trying to write a perl script to identify files with Windows EOL characters, but \r matching doesn't seem to work.
Here's my test script:
#!/usr/bin/perl
use File::Slurp;
$winfile = read_file('windows-newlines.txt');
if($winfile =~ m/\r/) {
print "winfile has windows newlines!\n"; # I expect to get here
}
else {
print "winfile has unix newlines!\n"; # But I actually get here
}
$unixfile = read_file('unix-newlines.txt');
if($unixfile =~ m/\r/) {
print "unixfile has windows newlines!\n";
}
else {
print "unixfile has unix newlines!\n";
}
Here's what it outputs:
winfile has unix newlines!
unixfile has unix newlines!
I'm running this on Windows, and I can confirm in Notepad++ that the files definitely have the correct EOL characters:

