Dear Masters,
How can I get my code below
use Data::Dumper; my %bighash; my $motif; my $score; my %hoa; my $tag; while ( <DATA> ) { chomp; my @aoa; if ( /^TAG/ ) { $tag = (split(/: /,$_))[1]; } elsif(/^MOTIF/) { ($motif,$score)=(split (/[\s,]/,$_))[1,3]; push @{$hoa{$motif}}, $score; } elsif(/^\d,-\d+,[ATCG]*$/) { @aoa = split(/,/,$_); push @{$hoa{$motif}}, [ @aoa ]; } #print Dumper \%hoa ; $bighash{$tag} = { %hoa }; } # ----- end while ----- print Dumper \%bighash; __DATA__ TAG: Set1 >instances MOTIF: CTTTTTAG, 10.6222222222222 Submotif: CTTTT TTTAT 2,-76,CTTTTTAG 2,-77,TCTTTTTA 3,-60,ACTTTTTG Decompose: 2,-16,CGTTTTTT CGTTT GTTTT TTTTT 1,-72,AATTTTAC ATTTT TTTTA TTTAC 2,-76,CTTTTTAG CTTTT TTTTT TTTTA TTTAG ============= MOTIF: CTTTTATC, 9 Submotif: GTTTT TTTTT 2,-76,CTTTTTAG Decompose: 2,-76,CTTTTTAG CTTTT TTTTT ============= TAG: Set2 >instances TAG: Set3 >instances MOTIF: TAGTTGAAAAAAATT, 17.8181818181818 Submotif: AAAAA AAATA AAATT 1,-49,CACACAAAAAATAAA 1,-82,AGTTGAAAAAAATTT Decompose: 1,-49,CACACAAAAAATAAA AAAAA AAAAA AAAAT AAATA 1,-82,AGTTGAAAAAAATTT AAAAA AAAAA AAAAA AAAAT AAATT AATTT =============
to capture "TAG: Set2" area that has no value. So that it gives something like this:
$VAR1 = { 'Set1' => { 'CTTTTTAG' => [ '10.6222222222222', [ '2', '-76', 'CTTTTTAG' ], [ '2', '-77', 'TCTTTTTA' ], [ '3', '-60', 'ACTTTTTG' ] ], 'CTTTTATC' => [ '9', [ '2', '-76', 'CTTTTTAG' ] ] }, 'Set3' => { 'TAGTTGAAAAAAATT' => [ '17.8181818181818', [ '1', '-49', 'CACACAAAAAATAAA' ], [ '1', '-82', 'AGTTGAAAAAAATTT' ] ], 'Set2' => { } };

In reply to Capturing No-values Region in Regex match 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.