in reply to Multidimensional Hash implementation/usage
Based on the code you provided a more perlish way to do what you want is:
#!/usr/perl5/5.6.1/bin/perl my %data; while ( <> ) { chomp; my ( $Fld1, $Fld14, $Fld15, $Fld67 ) = ( split /\|/, $_, -1 )[ 0, +13, 14, 66 ]; if ( $Fld1 != 800 && $Fld1 != 801 ) { my $key = join '|', substr( $Fld67, 2, 5 ), $Fld1, $Fld15; $data{ $key }{ count }++; $data{ $key }{ cost } += $Fld14; } } for my $l_strSwitch ( keys %data ) { print "\n$l_strSwitch|$data{$l_strSwitch}{count}"; }
|
|---|