while (<$fh>) { s/\x0D\x0A\z//; ... } #### local $/ = "\x0D\x0A"; while (<$fh>) { chomp; ... } #### while (<$fh>) { s/\s+$//; ... }