... or alternatively,
while (<DATA>) { if (/^>.*predicted_CDS/ ... /^$/) { print "CDS: $_" if /.+/; next; } if (/^>.*predicted_peptide/ ... /^$/) { print "PEP: $_" if /.+/; } } __DATA__ GENSCAN 1.0 Date run: 11-Mar-109 Time: 00:29:37 Sequence scaffold_2 : 47583 bp : 37.42% C+G : Isochore 1 ( 0 - 100 C+G +%) Parameter matrix: test.smat Predicted genes/exons: Gn.Ex Type S .Begin ...End .Len Fr Ph I/Ac Do/T CodRg P.... Tscr.. ----- ---- - ------ ------ ---- -- -- ---- ---- ----- ----- ------ 1.01 Init - 2604 2462 143 0 2 77 96 184 0.883 20.81 1.00 Prom - 3677 3638 40 2.82 2.00 Prom + 4382 4421 40 1.62 2.01 Init + 6395 6399 5 1 2 73 84 0 0.122 -0.16 2.02 Intr + 8270 8412 143 2 2 74 82 110 0.141 12.00 2.03 Term + 8516 8523 8 0 2 46 46 0 0.473 -8.05 2.04 PlyA + 9723 9728 6 2.27 Predicted peptide sequence(s): Predicted coding sequence(s): >scaffold_2|GENSCAN_predicted_peptide_1|48_aa MDRSHQIWDEKLMDQKCVLYPVCLWHEQESEMNWEAEKAERLRTEQKX >scaffold_2|GENSCAN_predicted_CDS_1|144_bp atggatcggagtcatcagatatgggatgagaagctgatggatcagaagtgcgtcctctac cccgtctgcctctggcacgagcaggagagcgagatgaactgggaggctgagaaagctgag aggctaaggactgaacagaaaggn >scaffold_2|GENSCAN_predicted_peptide_2|51_aa MRKNEGVDDADPLIEGMKEITLKDSATPEDKDQEDKQDERGEEIQEQPQEM >scaffold_2|GENSCAN_predicted_CDS_2|156_bp atgaggaagaatgagggtgttgatgatgcagatccactaatagaaggtatgaaggagatc actctgaaagattcagcaactccagaagacaaggatcaagaagacaaacaagatgagaga ggtgaagaaattcaagaacaacctcaagagatgtag
gives
pointo1d@unforgiven:~$ perl tst.pl PEP: >scaffold_2|GENSCAN_predicted_peptide_1|48_aa PEP: MDRSHQIWDEKLMDQKCVLYPVCLWHEQESEMNWEAEKAERLRTEQKX CDS: >scaffold_2|GENSCAN_predicted_CDS_1|144_bp CDS: atggatcggagtcatcagatatgggatgagaagctgatggatcagaagtgcgtcctctac CDS: cccgtctgcctctggcacgagcaggagagcgagatgaactgggaggctgagaaagctgag CDS: aggctaaggactgaacagaaaggn PEP: >scaffold_2|GENSCAN_predicted_peptide_2|51_aa PEP: MRKNEGVDDADPLIEGMKEITLKDSATPEDKDQEDKQDERGEEIQEQPQEM CDS: >scaffold_2|GENSCAN_predicted_CDS_2|156_bp CDS: atgaggaagaatgagggtgttgatgatgcagatccactaatagaaggtatgaaggagatc CDS: actctgaaagattcagcaactccagaagacaaggatcaagaagacaaacaagatgagaga CDS: ggtgaagaaattcaagaacaacctcaagagatgtag pointo1d@unforgiven:~$
Just modify the print as appropriate e.g. to previously opened files etc..

A user level that continues to overstate my experience :-))

In reply to Re: parsing sequences from a file by Bloodnok
in thread parsing sequences from a file by sugar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.