Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: use of eval and Data::Dumper

by broomduster (Priest)
on Sep 27, 2008 at 15:32 UTC ( #714027=note: print w/replies, xml ) Need Help??

in reply to use of eval and Data::Dumper

As an alternative to eval'ing your stored HoH, have a look at Storable (part of the Perl distribution).

Replies are listed 'Best First'.
Re^2: use of eval and Data::Dumper
by Anonymous Monk on Sep 27, 2008 at 16:04 UTC
    Thanks broomduster, Storable might be better.

    But I did find the solution:
    #!/usr/bin/perl -w use strict; use Data::Dumper; my @ray=qw(bob me other); my %hash; foreach (@ray) { %{$hash{$_}}=("one", "$_+1", "two", "$_+2", "three", "$_+3") } my $ref=\%hash; $Data::Dumper::Terse=1; # remove "$VAR" in output my $r2=Dumper($ref); my $answer = eval $r2; print Dumper($answer);
      No, you want Purity=1, and Terse=1 is a step away from what you want. Better:
      #!/usr/bin/perl -w use strict; use Data::Dumper; my $dump; { # Writer # ----- my $hash = {}; my @ray=qw(bob me other); foreach (@ray) { %{$hash->{$_}} = ( one => $_+1, two => $_+2, three => $_+3, ); } print(Dumper($hash)); $dump = Data::Dumper->new([ $hash ], [qw( $hash )]) ->Purity(1) ->Dump(); } { # Reader # ------ my $hash; eval "$dump; 1" or die $@; print(Dumper($hash)); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://714027]
[robby_dobby]: LA: That's there. But this is work and it's the same thing as falling asleep driving :-)
[Lady_Aleena]: I love the dream where I was at a huge house and decided to go swimming in the pool, but then the tour group showed up.
choroba fell asleep while driving half a year ago
[choroba]: fortunately, only the traffic sign and the car were damaged
[Discipulus]: fall asleep? coffee time!
Discipulus when in motorbike it is impossible to fall asleep.. another advantage

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2017-05-29 08:10 GMT
Find Nodes?
    Voting Booth?