#!/usr/bin/env perl use strict; use warnings; my %compare; $/=""; my $key; my $value; while (<>) { chomp; ( $key, $value ) = split('\t', $_); my @lines = split /\n/, $key; my $key1 = $lines[1]; push( @{ $compare{$key1} }, $value ); } foreach my $key1 ( sort keys %compare ) { my $tot = 0; my $file_count = @ARGV; for my $val ( @{$compare{$key1}} ) { $tot += ( split /:/, $val )[0]; } if ( @{ $compare{$key1} } >= $file_count) { print join( "\t", $key, $tot, @{ $compare{$key1} } ), "\n\n"; } }