in reply to Unix and Windows CRLF vs LF

On a Windows system (without binmode),
while (<$fh>) { # If the file contained lines ending with CRLF, $_ ends with LF # If the file contained lines ending with LF, $_ ends with LF chomp; # Removes LF }
On other systems,
while (<$fh>) { # If the file contained lines ending with CRLF, $_ ends with CRLF # If the file contained lines ending with LF, $_ ends with LF s/\r?\n\z//; # Removes CRLF or LF }

And since the latter works on Windows as well, you can just use it everywhere.

The only systems where this doesn't work are old Macs.