Here's another version. I was about to post it, but then I saw CountZero's solution above, which uses pretty much the same procedure. However, as mine looks more concise, I thought, why not? FWIW:
my $elem = 1; my $k = 3; my %out; while ( <DATA> ) { next unless /\b$elem\b/; $out{$_}++ for split; } delete $out{$elem}; print "$_ ($out{$_} times)\n" for (sort { $out{$b} <=> $out{$a} } keys %out)[ 0 .. ( $k - 1 ) ];
dave
In reply to Re: Re: Best Pairs
by Not_a_Number
in thread Best Pairs
by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |