perl -nle"push @{$h{$_}},$ARGV}{print qq[$_ found in @{$h{$_}}] for keys %h" 1.dat 2.dat 3.dat 4.dat 5.dat 6.dat 7.dat 8.dat 9.dat 10.dat