Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Extracting multiple rows in a text file with a regex.

by Skeeve (Vicar)
on Jul 28, 2013 at 09:02 UTC ( #1046723=note: print w/replies, xml ) Need Help??

in reply to Extracting multiple rows in a text file with a regex.

If you don't want to "slurp" in the whole file at once:

my $name; my $seq; while (<DATA>) { chomp; if (s/^Name:\s*//) { $name= $_; next; } if (s/^Nucleotide Sequence:\s*//) { $seq= $_; while (<DATA>) { last if /^s*$/; chomp; $seq.= $_; } print "$name\n$seq\n\n"; } } __DATA__ GeneID: 1002 Name: cadherin 4, type 1, R-cadherin (retinal) Chromo: 20 Cytoband: 20q13.3 Nucleotide Sequence: atgaccgcgggcgccggcgtgctccttctgctgctctcgctctccggc acagcgagactggagatatcgtcacagtggcggctggcctggaccgagagaaagttcagcagtacacag cagcttgcgcatcctgtacctggaggccgggatgtatgacgtccccatcatcgtcacagactctggaaa GeneID: 10077 Name: tetraspanin 32 Chromo: 11 Cytoband: 11p15.5 Nucleotide Sequence: atggggccttggagtcgagtcagggttgccaaatgccagatgctggtc GeneID: 10078 Name: tumor suppressing subtransferable candidate 4 Chromo: 11 Cytoband: 11p15.5 Nucleotide Sequence: atggctgaggcaggaacaggtgagccgtcccccagcgtggagggcgaa


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1046723]
and not a whimper to be heard...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-01-18 14:29 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.