HI All, I would like your input on how to solve my problem with one to many relation ship. This is how the data come to the code:
tar : ERGC [1] | ALX5 [2] | PT2 [3] | PRTD [4] act: Ago [1] : Inhib +it [2,3,4]
I need to insert in my database ERGC and AGO and the rest ALX5, PT2,PRTD all should have inhibit. like :
insert into Table1 values(sq_tab1.nextval,'ERGC','AGO'); insert into table1 values(sq_tab1.nextval,'ALX5','inhibit'); insert into table1 values(sq_tab1.nextval,'PT2','inhibit'); insert into table1 values(sq_tab1.nextval,'PRTD','inhibit');
I have a code that parses the input to a format of : actual target ERGC and its reference 1 and similarly actual action AGO and its reference 1,2 or 1,2,3,4.
my @targets = split (/\|/,$mech_results->{'Targets'}); my @actions = split (/\|/,$mech_results->{'Mechanism of Action_typ +e'} ); my $a = sprintf "targets: %s | actions: %s |", join( ":", @targets + ), join ( ":", @actions ); warn $a; my $iteration = each_array(@targets,@actions); #my ($targets,$actions) = targetsSynced(\@targets,\@actions); #warn scalar @targets. '|' . @actions; if(scalar @targets eq scalar @actions){ }else{ while(my($targets,$actions) = $iteration->()){ next if ($targets|$actions) eq ''; # targets with more than one reference. if($targets =~ /(\(?\w+\))?(?:[ \/](.*))/){ my ($target, $tar_ref) = $targets =~ /\(?(\w+)\)?(?:[ \/]( +(.*)))/; my ($tarref_no) = $tar_ref =~ /\[(\d)\]/; my ($action,$act_ref) = $actions =~ /(.*)?\s\[(.*)\]/; my @act = split(/,/,$act_ref); foreach my $af(@act){ #warn "$af,$tarref_no $target, $action"; } } }
But with this I get this:
1,1 ERGC, Ago 2,2 ALX5, Inhibit 3,2 ALX5, Inhibit 4,2 ALX5, Inhibit
But I would like to have
1,1 ERGC, Ago 2,2 ALX5, Inhibit 3,3 PT2, Inhibit 4,4 PRTD, Inhibit
Any suggestion please. Thanks

In reply to how to access the data to one to many relationship by Anonymous Monk

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.