- 论坛徽章:
- 5
|
{:2_167:}- HP:0000098 <=> HP:0004322;HP:0001510
复制代码 {:2_168:}
0000098
1: 0001510 => real
2: 0004322 => fake: => 0001510's 子- HP:0000022 <=> HP:0001510, HP:0001511
- HP:0001510 <=> HP:0004322
- HP:0000098 <=> HP:0001510
- HP:0000002 <=> HP:0000098
- HP:0010002 <=> HP:0001511, HP:0001510
复制代码- my %family;
- while (<DATA>) {
- my @person = split /;|\s+/;
- my $son = pop @person;
-
- $family{$_}{$son} = 1 for @person;
- }
- for my $person ( keys %family ) {
- my ( @maybe, @sons ) = keys %{ $family{$person} };
-
- try: for my $son (@maybe) {
- exists $family{$_}{$son} and next try for @maybe;
- push @sons, $son;
- }
-
- say "$person <=> ", join ', ', @sons;
- }
-
- __DATA__
- HP:0000002 HP:0000098
- HP:0000002;HP:0001510 HP:0004322
- HP:0000098;HP:0000022;HP:0010002 HP:0001510
- HP:0000098 HP:0004322
- HP:0000022;HP:0010002 HP:0001511
复制代码 回复 3# huang6894
|
|