(updated thanks to syntax catch by Wind)use Data::Dumper; my %pairs = (); while (<>) { chomp; my @found = split; for my $k1 ( @found ); for my $k2 ( @found ) { if ( $k2 gt $k1 ) { # ensuring each pair is counted once o +nly for the line $pairs{ $k1 }{ $k2 }++; } } } } print Dumper \%pairs;
One world, one people
In reply to Re: counting pairwise incidences
by anonymized user 468275
in thread counting pairwise incidences
by reubs85
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |