in reply to How to avoid using array in concatenating string of multiple lines OR How To Read FASTA

This is most likely not the best or prettiest way of doing it, but I think it works. :-)
my $counter = 1; my $tmp = ''; foreach(<DATA>) { chomp; if (!/^>/) { $tmp .= $_; } else { print $counter++, " : $tmp\n" if length $tmp; $tmp = ""; } } print $counter, " : $tmp\n" if length $tmp;


Update: Oops, missing chomp.
  • Comment on Re: How to avoid using array in concatenating string of multiple lines
  • Download Code