The output you showed does not match the output I get - your s/\s+//g; to remove all whitespace seems to be working fine. So it seems like the code you showed here does not match your input and/or output, please make sure to provide consistent examples. See How do I post a question effectively? and Short, Self-Contained, Correct Example. Also, please use <code> tags to format input and output in addition to your code.
Athanasius has pointed out that you are adding extra newlines to the output. Another important point here is that you are reading the input line-by-line, so that the print OUT "Genome: \n" happens on every line of input. What Athanasius's code is doing instead is printing the "Genome:" once, before all the data, and then printing the data with all newlines removed, which works because print does not add newlines to the output by default (that means print "a"; print "b"; print "c"; writes "abc" to the output one character at a time).
A couple more tips: I strongly recommend you clean up your formatting, that'll make it easier for you and for us to read your code - perltidy can help with that. Also, since I don't see the declaration of $line, make sure that you Use strict and warnings and only declare your variables at the smallest scope necessary (e.g. while ( my $line = <$in_fh> )). And one more nit: "escape" usually means to take a special character and turn it into plaintext, for example turning "\n" into "\\n" such that in the output, instead of a newline, you get two visible characters, \n. I think your question would be better described as "removing all newlines".
In reply to Re: how to escape new line in a string
by haukex
in thread how to escape new line in a string
by nica
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |