Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Odd hash problem

by imp (Priest)
on Feb 23, 2007 at 16:05 UTC ( #601756=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Odd hash problem
in thread Odd hash problem

That depends on how the hash was stored.

You could use Storable to freeze/thaw the hash like this:

use strict; use warnings; use Storable qw(freeze thaw); use Data::Dumper; my %orig = ( 1 => 2, a => 'b'); my $frozen = freeze(\%orig); print "Frozen: $frozen\n"; my $restored = thaw($frozen); print "Thawed: ", Dumper $restored;
Or you could be lazy (and insecure) and use Data::Dumper and eval like this:
use strict; use warnings; use Data::Dumper; $Data::Dumper::Purity = 1; $Data::Dumper::Terse = 1; my %orig = ( 1 => 2, a => 'b'); my $frozen = Dumper(\%orig); print "Frozen: $frozen\n"; my $restored = eval $frozen; print "Thawed: ", Dumper $restored; print "Error: $@\n";


Comment on Re^3: Odd hash problem
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2015-07-28 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls