in reply to Perl Hash
prints:use strict; use warnings; my %h; while (<DATA>){ chomp; next if length($_) < 30; my ($k1, $k2,$k3, $val) = unpack("A8 x1 A15 x1 A33 x1 A5", $_); $h{$k1}{$k2}{$k3} += $val; } for my $k1 (sort keys %h){ print "$k1\n"; for my $k2 ( sort keys %{ $h{$k1} } ) { print "\t$k2\n"; for my $k3 ( sort keys %{ $h{$k1}{$k2} } ) { print "\t\t$k3 $h{$k1}{$k2}{$k3}\n"; } } } __DATA__ Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 20.32 Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 24.00 Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 20.59 Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 24.00
Summary Detial_Summary EMC CHECK abcdefghi AZ_checker 1 44.32 Summary1 Detial_Summary1 EMC CHECK1 abcdefghi AZ_checker 1 44.59
"I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
-- Dr. Cox, Scrubs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Hash
by Rajsai2825 (Novice) on Apr 17, 2013 at 05:23 UTC | |
by NetWallah (Canon) on Apr 17, 2013 at 05:44 UTC |