#!/usr/bin/perl
@foo= ("apple","orange","pear","pear","mango","apple");
for (@foo) {
$bar{$_}++;
}
while ( ($k,$v) = each %bar ) {
if ($v =~ 1){
print "$k appears $v time\n";
}
elsif ($v !=~ 1){
print "$k appears $v times\n";
}
}
####
apple
orange
pear
pear
mango
apple
####
apple Tom
orange Tom
pear Tom
mango David
apple David
####
APPLE appears 2TIMES associated with TOM and DAVID
ORANGE appears 1TIME associated with TOM
...e.t.c