my %compare; $/=""; while (<>) { chomp; my ( $key, $value ) = split('\t\s', $_); push( @{ $compare{$key} }, $value ); } foreach my $key ( sort keys %compare ) { my $tot = 0; my $file_count = @ARGV; for my $val ( @{$compare{$key}} ) { $tot += ( split /:/, $val )[0]; } if ( @{ $compare{$key} } >= $file_count) { print join( "\t", $key, $tot, @{ $compare{$key} } ), "\n\n"; } }