#!/usr/bin/perl -w use strict; use Data::Dumper; use Data::Dump qw (pp); my %animals; my %verbs; # Your say, "In the example above, the only feat that occurs # both with beast and frog is kill-v". # # I don't see it # Obviously there is something that I don't understand... # # this simple code gets multiple things in common # I don't understand how to filter out "see-v" and "turn-v" # Prints: # turn-v: beast-n frog-n # see-v: beast-n frog-n # kill-v: beast-n frog-n while () { my ($animal, $verb) = (split(' ', $_))[1,3]; $animals{$animal}++; push @{$verbs{$verb}}, $animal; } foreach my $verb (keys %verbs) { if (@{$verbs{$verb}} > 1) { print "$verb: @{$verbs{$verb}}", "\n"; } } __DATA__ 1 beast-n into transform-v 356.9551 2 beast-n obj kill-v 266.2511 3 beast-n obj see-v 252.3623 4 beast-n prd become-v 250.9534 5 beast-n obj tame-v 224.6948 6 beast-n into turn-v 191.9883 7 beast-n obj call-v 171.4000 8 beast-n sbj_intr devour-v 165.3228 9 beast-n obj hunt-v 155.7637 10 beast-n obj fight-v 150.4370 11 beast-n obj slay-v 150.3982 1 frog-n obj find-v 322.5589 2 frog-n into turn-v 307.3012 3 frog-n sbj_intr jump-v 235.0503 4 frog-n coord-1 toad-n 207.3611 5 frog-n obj see-v 207.2610 6 frog-n obj eat-v 204.1762 7 frog-n obj kill-v 64.6689