Dear Masters,
My code below has no problem capturing such data:
__DATA__ >r4713.1 |SOURCES={GI=162960844,bw,7184325-7184361} >r4714.1 |SOURCES={GI=162960844,fw,6257219-6257255}
How can generalize the regex in my code such that it also support the following entries?
# note that there can me more than two "GI"s inside the {} bracket __DATA__ >r7.1 |SOURCES={GI=162960844,bw,0-4;GI=162960844,bw,9025576-9025608}| >r6.1 |SOURCES={GI=152989753,bw,0-30;GI=152989753,bw,1877925-1877931}|
My code:
use Data::Dumper; my %all_entry; while (<DATA>) { chomp; next unless (/^>/); my $line = $_; $line =~ />.*\{GI=(\d+),(\w+),(\d+\-\d+)\}/g; # 'g' doesn't seem to work #print "$line --- $1 $str{$2} $3\n"; push @{ $all_entry{$1}{$2} }, $3; } print Dumper \%all_entry; __DATA__


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

In reply to Generalizing Regex with Multiple 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.