OUTPUT: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 $entr +y->{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"; } }
HOST:aaaa: 32859 IDB HOST:bbbb: 14 SAP
"Software interprets lawyers as damage, and routes around them" - Larry Wall
In reply to Re: Array of hashes
by NetWallah
in thread Array of hashes
by AnishaM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |