Jason.
I believe that this is the answer you are looking for. I was not aware of
this usage. It's pretty obscure.
If you are using hash references, so that
$foo{a}{b} = 'hello' ;
$foo{c}{d} = 'world' ;
Then get the complete list of keys as follows
@keys = map { keys %$_ } keys %foo ;
print join ' ', @keys, "\n" ; ## results (order indeterminate): a b c d
chain many dimensioned hashes together like this (be prepared for errors):
@keys = map { keys %$_ } map { keys %$_ } keys %foo
Regarding your specific question:
$foo{ 'a', 'b' } = 'hello' ;
$foo{ 'c', 'd' } = 'world' ;
@keys = map { split /$;/ } keys %foo ;
print join ' ', @keys, "\n" ; ## results (order indeterminate): a b c d
HTH,
-Jim
On Wed, 29 Dec 2004 [EMAIL PROTECTED] wrote:
> > Sorry for the horribly lame question, but I am not having any luck
> > finding an answer, probably because I don't know how to phrase the
> > question properly.
> >
> > When I have a hash defined by multiple keys, how can I pull both keys
> > out?
> >
> > $hash{$key1, $key2} = $data;
>
> This is equivalent to
> $hash{join($;, $key1, $key2)} = $data;
> so you need to split on the value of $; to extract the individual keys.
>
> --
> Eric Amick
> Columbia, MD
--
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs