Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to avoid using array in concatenating string of multiple lines

by pingo (Hermit)
on Dec 09, 2004 at 10:44 UTC ( #413472=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2020-12-05 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?