use strict; use warnings; open(my $fh, '<', 'test.txt') or die $!; my $count = 0; while (<$fh>) { $count++ if /\r/; } close $fh; print "Without :crlf, \$count=$count\n"; open($fh, '<:crlf', 'test.txt') or die $!; $count = 0; while (<$fh>) { $count++ if /\r/; } close $fh; print "With :crlf, \$count=$count\n"; #### Without :crlf, $count=10 With :crlf, $count=0