in reply to Re: use of eval and Data::Dumper
in thread use of eval and Data::Dumper

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);

Replies are listed 'Best First'.
Re^3: use of eval and Data::Dumper
by ikegami (Patriarch) on Sep 27, 2008 at 19:00 UTC
    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)); }