http://qs321.pair.com?node_id=1077623


in reply to Replace new line with white space

I suspect that what you really need is chomp, and that you don't need a regex at all.
while (<$fh>) { chomp; # Line in $_ no longer has trailing \n
However, without seeing your code we can't confidently advise you either way.