I\'m maintaining a script that can get its input from various sources, and works on it per line. Depending on the actual source used, linebreaks might be Unix-style, Windows
Whenever I go through input and want to remove or replace characters I run it through little subroutines like this one.
sub clean { my $text = shift; $text =~ s/\n//g; $text =~ s/\r//g; return $text; }
It may not be fancy but this method has been working flawless for me for years.