K_Edw has asked for the wisdom of the Perl Monks concerning the following question:
Given a tab-delimited .txt file where data comes in pairs of lines, such as:
1 7 848773 75 A 74 1 7 848576 74 A 0 2 16 785802 75 A 0 2 16 786009 75 A 74 3 7 848576 75 A 74 3 7 848773 74 A 0
I wish to tally the frequency of all unique number combinations - in the above example the desired output is:
7 848576 848773 2 16 785802 786009 1
848773-848576 being the same as 848576-848773.
I'm not sure how to solve this problem. I'm accessing each pair of lines via:my @F2 = split("\t", $_); my $partner = <$IN2>; my @F3 = split("\t", $partner);
And then thought to use a multi-dimensional hash:
However this would not handle equivalent pairs - which is the part i'm not sure how to do or how I would then print it out easily. What would be a good way to do it?my %count; $count{$F2[1]}{$F2[2]}{$F3[2]}++;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tallying co-occurence of numbers
by choroba (Cardinal) on Jun 17, 2016 at 13:32 UTC | |
by K_Edw (Beadle) on Jun 17, 2016 at 13:34 UTC | |
|
Re: Tallying co-occurence of numbers
by BrowserUk (Patriarch) on Jun 17, 2016 at 14:22 UTC | |
by K_Edw (Beadle) on Jun 17, 2016 at 20:02 UTC | |
by BrowserUk (Patriarch) on Jun 17, 2016 at 20:28 UTC | |
by K_Edw (Beadle) on Jun 18, 2016 at 09:38 UTC | |
by BrowserUk (Patriarch) on Jun 18, 2016 at 10:02 UTC | |
by BrowserUk (Patriarch) on Jun 18, 2016 at 15:51 UTC |