in reply to Parsing lines containing extra carriage returns

If you have carriage returns (in addition to newlines) in your lines, just delete them first:

while <FILE> { tr/\r\n//d; # etc.
The above will replace chomp as well.

If you have blank lines (two consecutive newlines), you can just detect them after the tr:

tr/\r\n//d; next if $_ eq '';