Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Hash to Scalar?

by ph0enix (Friar)
on Dec 09, 2002 at 13:43 UTC ( #218515=note: print w/replies, xml ) Need Help??


in reply to Hash to Scalar?

You can use Storable

use Storable qw(nfreeze thaw); $scalar = nfreeze(\%hash); %hash_copy = %{ thaw($scalar) };

If you need to have hash with keys - usenames and values as data structure (not scalar) you can use tie... for binding to sql database use eg. Tie::RDBM module. Example from docs:

use Tie::RDBM; tie %h,Tie::RDBM,'mysql:test',{table=>'Demo',create=>1,autocommit=>0}; $h{'key1'} = 'Some data here'; $h{'key2'} = 42; $h{'key3'} = { complex=>['data','structure','here'],works=>'true' }; $h{'key4'} = new Foobar('Objects work too'); print $h{'key3'}->{complex}->[0]; tied(%h)->commit; untie %h;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://218515]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2023-06-05 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (24 votes). Check out past polls.

    Notices?