#!/usr/local/bin/perl use strict; my %total; opendir(D, "/tmp/") || die "cannot opendir /tmp/: $!\n"; foreach my $file (grep {/^ips_to_scan\.\d+\.log$/} readdir D){ open(F, "/tmp/$file") || die "cannot open /tmp/$file: $!\n"; while(){ my ($label,$value) = split /[=:]/; $total{$label} += $value; } close F; } closedir D; foreach my $key (sort keys %total){ print "$key => $total{$key}\n"; }