Dear Masters,
How can I parse this text:
__DATA__ Pm 0.2707 Minimum match (10/15) Top 3 motifs Wid Score1 Segment Con Deg Mtf 1 15 1.700 10 CGATATCGATTCGTT CGATATYGAWTSSTT Final Motif 1: Wid 15 Score1 1.700 Segment 10 A C G T Con rCon Deg rDeg 1 7 81 4 7 C G C G 2 23 4 66 7 G C G C 3 69 19 4 7 A T A T 4 7 4 4 84 T A T A 5 84 4 4 7 A T A T >2522963-2522975-reverse St b99 CGATATCGATGGATT >2522963-2522975-reverse St f145 CGATATCGAATCGCT >2522963-2522975-reverse St b155 CGATATTAATTCCTT >2522963-2522975-reverse St f156 CGCTATTGAATGCGT >2523043-2523055-reverse St b88 CAATAGCGATTCGAT Mtf 2 15 1.666 12 AATGAATCAATATCG AAKSAWTYRATATCG Final Motif 2: Wid 15 Score1 1.666 Segment 12 A C G T Con rCon Deg rDeg 1 73 4 17 6 A T A T 2 60 17 17 6 A T A T 3 6 17 30 46 T A K M 4 6 44 44 6 C G S S 5 46 17 17 20 A T A T >2522963-2522975-reverse St b81 ACGCATTCAATAGCG >2522963-2522975-reverse St f82 AAGGAATTAATATCG >2522963-2522975-reverse St b92 AGCGATTCGATATCG >2522963-2522975-reverse St b106 GATGGATTTATATCT >2522963-2522975-reverse St f138 AATCCATCGATATCG Mtf 3 15 1.656 10 TCGATATCGAATGGC TCGMTATCGAWTSGC Final Motif 3: Wid 15 Score1 1.656 Segment 10 A C G T Con rCon Deg rDeg 1 7 4 4 84 T A T A 2 7 81 4 7 C G C G 3 23 4 66 7 G C G C 4 54 35 4 7 A T M K 5 7 4 4 84 T A T A 6 84 4 4 7 A T A T 7 7 4 19 69 T A T A 8 23 50 4 23 C G C G 9 23 4 66 7 G C G C 10 84 4 4 7 A T A T 11 54 4 4 38 A T W W 12 23 4 19 54 T A T A 13 7 35 50 7 G C S S 14 23 19 50 7 G C G C 15 23 35 19 23 C G C G >2522963-2522975-reverse St b87 TCAATAGCGATTCGA >2522963-2522975-reverse St b98 TCGATATCGATGGAT >2522963-2522975-reverse St f144 TCGATATCGAATCGC >2522963-2522975-reverse St f155 TCGCTATTGAATGCG >2522963-2522975-reverse St f204 TCGCTATAAAAAGGC Total time 0:0:0.
So that it return this AoA:
$VAR = [ ['CGATATYGAWTSSTT', '>2522963-2522975-reverse St f145 CGATATCGAATCGCT', '>2522963-2522975-reverse St f156 CGCTATTGAATGCGT',], ['AAKSAWTYRATATCG', '>2522963-2522975-reverse St f82 AAGGAATTAATATCG', '>2522963-2522975-reverse St f138 AATCCATCGATATCG',], ['TCGMTATCGAWTSGC', '>2522963-2522975-reverse St f144 TCGATATCGAATCGC', '>2522963-2522975-reverse St f155 TCGCTATTGAATGCG', '>2522963-2522975-reverse St f204 TCGCTATAAAAAGGC',] ];
Note that we: I am totally lost right from the beginning:
use warnings; use strict; use Data::Dumper; use Carp; my @aoa; my @temp; while (<DATA>) { chomp; if (/^Mtf (\d+) (.*) ([A-Z]+)$/) { # stuck here print "$_ \n"; push @temp, ($3); } elsif (/^>(\w+) St (b|f)\d+/) { # not sure how to capture only "f" + here print "$_\n"; } push @aoa, [@temp]; } #print Dumper \@aoa ;


---
neversaint and everlastingly indebted.......

In reply to Selective Parsing Problem by neversaint

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.