in reply to Multidimensional Hash implementation/usage
my $idx = substr $Fld57, 3, 5; $CNT{$idx}{$Fld1}{$Fld15}++; $COST{$idx}{$Fld1}{$Fld15} += $Fld14;
The second possibility is to use a separator to join the indexes. Be sure that the separator doesn't occur in the indexes:
my $idx = substr $Fld57, 3, 5; $CNT{$idx . $Fld1 . $Fld15}++; $COST{$idx . $Fld1 . $Fld15} += $Fld14;
(. is string concatenation).
Depending on how you want to retrieve your data, one or the other version might be more suitable for you.
The usual hints apply: always start your programs with
use strict; use warnings;
and declare your variables with my.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multidimensional Hash implementation/usage
by salva (Canon) on Sep 17, 2007 at 08:44 UTC | |
|
Re^2: Multidimensional Hash implementation/usage
by subhankar (Novice) on Sep 17, 2007 at 06:57 UTC | |
by moritz (Cardinal) on Sep 17, 2007 at 07:28 UTC | |
by planetscape (Chancellor) on Sep 17, 2007 at 18:20 UTC | |
by subhankar (Novice) on Sep 17, 2007 at 08:29 UTC | |
by graff (Chancellor) on Sep 17, 2007 at 13:04 UTC |