Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need to insert in my database ERGC and AGO and the rest ALX5, PT2,PRTD all should have inhibit. like :tar : ERGC [1] | ALX5 [2] | PT2 [3] | PRTD [4] act: Ago [1] : Inhib +it [2,3,4]
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.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');
But with this I get this: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 I would like to have1,1 ERGC, Ago 2,2 ALX5, Inhibit 3,2 ALX5, Inhibit 4,2 ALX5, Inhibit
Any suggestion please. Thanks1,1 ERGC, Ago 2,2 ALX5, Inhibit 3,3 PT2, Inhibit 4,4 PRTD, Inhibit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to access the data to one to many relationship
by choroba (Cardinal) on Mar 22, 2015 at 20:34 UTC | |
by Anonymous Monk on Mar 23, 2015 at 12:29 UTC | |
by choroba (Cardinal) on Mar 23, 2015 at 13:19 UTC | |
by Anonymous Monk on Mar 23, 2015 at 15:43 UTC |