Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661847]
help
Chatterbox?
[choroba]: csh considered harmful
[erix]: no, I'm using bash :)
[marioroy]: :)
[marioroy]: I use the default and happens to be bash
[erix]: heh, I like the "Resolved" (Christiansen is really funny)
Discipulus is makita a reincarnation of grinder?
[erix]: I probably also need to understand TAP a bit better than I do

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-03-23 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.