in reply to Relationships between hash Data
_______________________________________________________
$SUBSCRIPT_SEPARATOR
$SUBSEP
$;
The subscript separator for multidimensional array emulation. If you refer to a hash element as
$foo{$a,$b,$c}
it really means
$foo{join($;, $a, $b, $c)}
But don't put
@foo{$a,$b,$c} # a slice--note the @
which means
($foo{$a},$foo{$b},$foo{$c})
Default is ``\034'', the same as SUBSEP in awk. If your keys contain binary data there might not be any safe value for $;. (Mnemonic: comma (the syntactic subscript separator) is a semi-semicolon. Yeah, I know, it's pretty lame, but $, is already taken for something more important.)
Consider using ``real'' multidimensional arrays as described in the perllol manpage.
_______________________________________________________
So you could set $; to something that isnt so 'ugly' or more intelligently use a two level hash, often called a HOH like so:
Reversing the relationship or using both can also be useful. Of course putting them together into titles involves an extra loop but ultimately I'd say this is the way to go.use Data::Dumper; my (%Sales,%Years); #.... ++$Sales{$sale_name}->{$fy}; # fy = Fiscal Year # and/or ++$Years{$fy}->{$sale_name}; # fy = Fiscal Year #.... print Dumper(\%Sales,\%Years); # _very_ usefull tool. # Less useful, but more obvious than messing with $; ++$count->{"$sale_name : $fy"}; # fy = Fiscal Year
HTH
Yves / DeMerphq
--
Have you registered your Name Space?
|
|---|