in reply to $var{'a',1,...}
Straight from the Camel's mouth:
You can emulate a multidimensional hash by specifying more than one key within the braces, separated by commas. The listed keys are concatenated together, separated by the contents of $; ($SUBSCRIPT_SEPARATOR), which has a default value of chr(28). The resulting string is used as the actual key to the hash.
I highly recommend the Camel book: Programming Perl, 3rd Edition, published by O'Reilly & Associates.
And of course there is also the POD: perlvar:
$;
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 perllol.
It's a syntax you just don't see that often. Most people who know about its existance are already so comfortable with complex datastructures built by using Perl's references that this syntax is set aside in favor of a more powerful tool.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $var{'a',1,...}
by ysth (Canon) on May 22, 2005 at 19:37 UTC |