in reply to Is it possible to assign an array reference to a value in hash

Is it possible to assign a array reference as a value to a hash key ?

You can use array references as keys in just the way you might guess that you can... the limitation is that you can't retrieve the key and then dereference it. This is because hash keys are strings by definition and when you use a reference as a key, it stringifies the reference first.

You probably want Tie::Refhash to do what you want to do.

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Is it possible to assign an array reference to a value in hash

Replies are listed 'Best First'.
Re^2: Is it possible to assign an array reference to a value in hash
by snape (Pilgrim) on May 15, 2012 at 02:21 UTC

    I am talking about the "value" to a hash key not key as an array reference.

    I am able to deference the value when I use it as an array reference. Thanks for the suggestions.

      It is unclear whether you consider your (updated) question answered.

      To complete stevieb's example, you can retrieve a value thusly:

      my $retrieve = $hash{ key } -> [1] ; # returns "b" (The "->" is opti +onal)

                   I hope life isn't a big joke, because I don't get it.
                         -SNL