Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Problem to store referrence as key value in a hash

by perladdict (Chaplain)
on Jan 11, 2008 at 10:23 UTC ( #661847=note: print w/replies, xml ) Need Help??

in reply to Problem to store referrence as key value in a hash

In your example $key stores the reference as string,so you can't convert
string back to reference,it will not returns a hard reference.

There is one special kind of hash Tie::RefHash in which we can store reference as keys.
Below is the code i tried,it may help you to store reference as key in a hash.

use Tie::Refhash; tie %hash 'tie::RefHash'; %hash =( ["one","two"] => "numbers", ["pen","book"]=> "stationery"); while(my($keyref,$value)=each %h)) { print "@$keyref has $value\n"; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661847]
marioroy it's taken so long, but MCE::Shared 1.827 is near the finish line. I want to add more to the documentation before making a release. This post is good to go. Github is current as well.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2017-08-18 07:33 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (295 votes). Check out past polls.