# Works on unix. # Works on Windows. # Works on Mac. { open(my $fh, '<', $input_file) or die "Couldn't open file $input_file: $!\n"; binmode($fh); my $buf = ''; while (read($fh, $buf, 1024, length($buf))) { if (/\x0D\x0A/) { die("DOS files not allowed\n"); } $buf = substr($buf, -1); } } { open(my $fh, '<', $input_file) or die "Couldn't open file $input_file: $!\n"; while (<$fh>) { $total_lines++; } }