Dear Parys,
Here is one way to do it [code] use strict; use warnings; my $str = "attttgctagccgagctaNNNNNNatggctaNNNNNNNatgcccctgaNNNNNNatg"; $str =~ s/N+/\n/g; ############### #Print the string as is (commented out) #print $str, "\n"; ############### print '-' x 40,"\n"; #Split the string on newline and store it in an array my @lines = split '\n', $str; print join "\n", @lines; print "\n", '-' x 40,"\n"; [/code] [output] ---------------------------------------- attttgctagccgagcta atggcta atgcccctga atg ---------------------------------------- [/output] best, Shaji ------------------------------------------------------------------------------- Your talent is God's gift to you. What you do with it is your gift back to God. ------------------------------------------------------------------------------- On Friday, 14 February 2014 1:19 PM, Parysatis Sachs <parysatissa...@gmail.com> wrote: Hi everyone! I'm new to this mailing list as well as to programming and Perl in general. So there is a chance I might ask relatively stupid questions with very obvious answers... Please bear with me! So, here it goes: I have a very long string with lots of Ns in it, like this: attttgctagccgagctaNNNNNNatggctaNNNNNNNatgcccctgaNNNNNNatg So, I want to get rid of the Ns and get ONE SINGLE newline for each group of Ns So far I've managed to do this: if ($joinedDNA =~ s/N+/\n/g) { $joinedDNA =~ s/\R//g; } But now I have everything joined together and can't tell where the Ns were before. I want output like so: attttgctagccgagcta atggcta atgcccctga atg Thanks for your help everybody, I really appreciate it! Parys -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/