Here is a slightly different approach to zwon's where I only read the file in one place and use state variables to keep track of where we are in the data file.

use strict; use warnings; my $frgFile = q{spw768164.frg}; open my $frgFH, q{<}, $frgFile or die qq{open: < $frgFile: $!\n}; my $inFRG = 0; my $inSeq = 0; while( <$frgFH> ) { if( $inFRG ) { if( m|^\}| ) { $inFRG = 0; } elsif( $inSeq ) { if( m{^\.} ) { $inSeq = 0; } else { print; } } elsif( m{^acc:(\d+)} ) { print qq{>$1\n}; } elsif( m{^seq:} ) { $inSeq = 1; } else { ; } } else { next unless m|^\{FRG|; $inFRG = 1; } } close $frgFH or die qq{close: < $frgFile: $!\n};

The output.

>1101077781160 acaaggctggagtatttttttgtttagtaatttatttaattcagtttttatattttcataaactttttta ggatcaccagggccattacttaaaaaaaaaccatcaaaatttctattaattatatcctcagcattaaaat tgatctttagagagaaacttacctttgaaaatatattttttgttataaattaaatatccgttttgataat taagtttagttttattatctaatacgggcatattaaatcatgtgtattagtatattatatcaaaggaaat tcaaatgagtttggcaaaaaaatttctgatgacgttaaagtgctttaaaaggcggagatagaaaaacttt catagcaaggtatgtctattctgagttaaaaattttctattaaagaaatctagagagagacgtgcttaat tatctgacga >1101077781161 gcgtgacgtttgagcagaagaattatttattaatttctgaggattttaagtctttaaaacaaaacgtttc attcaaatttcaaaatcttgattataaagaagcgatggcactaatggctgagattggcaatattaatata caactggctcagcagtattaaaaattgaactagatgcgttggaatctcaagggttaggaagaacagtttc taatccaaattgtttaccctagacaatcaaactgccagtattaaac

I hope this is of interest.

Cheers,

JohnGG


In reply to Re: Vertical Regex by johngg
in thread Vertical Regex by joomanji

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.