my $file_count = @ARGV;
foreach my $key1 ( keys %seen ) {
if ( @{ $seen{$key1} } >= $file_count) {
print join( "\t", @{$seen{$key1}});
print "\n\n";
}
}
####
# At the top of the file
use constant {
Key => 0,
Sum => 1,
Count => 2, # Remove this if you don't use the total count
Files => 3 # Should be 2 if Count is not used.
};
####
# In the read loop
$seen{$key1}[Key] //= $key;
$seen{$key1}[Sum] += $value;
$seen{$key1}[Count]++; # Total count for the number of times this value exists
$seen{$key1}[Files]{$ARGV}++; # Count in this file
####
use Data::Dumper;
while (<>)
{
# Your code here
}
print Dumper(\%seen);
####
use YAML;
while (<>)
{
# Your code here
}
print YAML::Dump(\%seen);