use strict; use warnings; my ($outer_hash, $new_hash); $outer_hash->{backupsize} = [{ 'totalsize' => '89', 'hostname' => 'aaaa', 'application' => 'IDB' }, { 'application' => 'IDB', 'hostname' => 'aaaa', 'totalsize' => '32770' }, { 'application' => 'SAP', 'hostname' => 'bbbb', 'totalsize' => '14' }]; for my $entry(@{ $outer_hash->{backupsize} }){ next unless $entry->{hostname} and $entry->{application} and $entry->{totalsize}; $new_hash->{$entry->{hostname}} {$entry->{application}} += $entry->{totalsize}; } for my $h (sort keys %$new_hash){ print "HOST:$h:\n"; for my $app(keys %{ $new_hash->{$h}}){ print "\t",$new_hash->{$h}{$app},"\t$app\n"; } }