It's not entierly clear what you are tryng to achieve. But on the guess that it is something to do with finding transitive relationships in the data, the following may be of use:
use strict; use warnings; my %mappings; while (<DATA>) { chomp; next if ! /\S/; s/^\s+//; s/\s+$//; my ($mainfile, $subfiles) = split /\s*,\s*/; my @subfiles = split /\s*;\s*/, $subfiles; $mappings{$mainfile} = [grep /\S/, @subfiles]; } # Print transitive relationships. ie: if A->B and B->C, then A->C for my $A (sort keys %mappings) { for my $B (@{$mappings{$A}}) { print " $A - $B -> @{$mappings{$B}}\n" if exists $mappings{$B} +; } } __DATA__ cancer,breast cancer; lung cancer; heart cancer; stomach cancer; breast cancer,foot cancer; foot cancer,some cancer; lung cancer,blood cancer; foot cancer; heart cancer,foot cancer; stomach cancer,foot cancer; blood cancer,some cancer;
Prints:
breast cancer - foot cancer -> some cancer cancer - breast cancer -> foot cancer cancer - lung cancer -> blood cancer foot cancer cancer - heart cancer -> foot cancer cancer - stomach cancer -> foot cancer heart cancer - foot cancer -> some cancer lung cancer - blood cancer -> some cancer lung cancer - foot cancer -> some cancer stomach cancer - foot cancer -> some cancer
In reply to Re: out of memory problem
by GrandFather
in thread out of memory problem
by perlbeginner10
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |