Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Hash to Scalar?

by ph0enix (Friar)
on Dec 09, 2002 at 13:43 UTC ( [id://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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-06-15 11:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.