in reply to how to access the data to one to many relationship
#!/usr/bin/perl use warnings; use strict; my $input = 'tar : ERGC [1] | ALX5 [2] | PT2 [3] | PRTD [4] act: Ago + [1] : Inhibit [2,3,4]'; my ($left, $right) = split /act:/, $input; my %num2left; while ($left =~ /(\S+) \[([0-9])\]/g) { $num2left{$2} = $1; } while ($right =~ /(\S+) \[([0-9,]+)\]/g) { my ($target, @indices) = ($1, split /,/, $2); for my $i (@indices) { print "$i $num2left{$i}\t$target\n"; } }
Output:
1 ERGC Ago 2 ALX5 Inhibit 3 PT2 Inhibit 4 PRTD Inhibit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to access the data to one to many relationship
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 |