Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there any ways to get this?
my $x; $x->{[1,2]} = 3; @xkeys = keys %{$x}; print $xkeys[0]->[0];
I am looking for some print out.

Replies are listed 'Best First'.
Re: ArrayRef as Hash key
by Fletch (Bishop) on Apr 20, 2010 at 18:32 UTC

    With vanilla perl hashes no; keys to hashes are stringified which will make the arrayref unrecoverable. That being said you can use the Tie::RefHash module to do what you want.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: ArrayRef as Hash key
by runrig (Abbot) on Apr 20, 2010 at 18:33 UTC
Re: ArrayRef as Hash key
by ikegami (Patriarch) on Apr 20, 2010 at 21:35 UTC

    Given this is a data structure design question, providing very specific broken code is not a good way of explaining what you want to do.

    my $x; push @$x, [ [1,2] => 3 ]; my @xkeys = map $_->[0], @$x; print $xkeys[0]->[0];
Re: ArrayRef as Hash key
by ssandv (Hermit) on Apr 20, 2010 at 20:38 UTC
    I suspect it would probably be more useful if you told us why you think that's what you want to do. This looks very likely to be an XY Problem