in reply to use of eval and Data::Dumper

You can turn $r2 back into a data structure like this:
my $data = eval "no strict; $r2";

The no strict is needed because the output from Data::Dumper has new variables without declaring them. Instead you could also tweak Data::Dumper's option prior to dumping.

Replies are listed 'Best First'.
Re^2: use of eval and Data::Dumper
by Your Mother (Archbishop) on Sep 27, 2008 at 19:01 UTC

    (Update: D'oh, I missed that "Terse" had already been mentioned above.)

    To the OP, not moritz: I don't recommend Data::Dumper. YAML or Storable (or even JSON if it fits with what you're doing; JSON::XS is--last I checked--the fastest serializer in Perldom) are preferable. I'm just adding that you can get Data::Dumper to emit raw data (no variable at all so you can skip the no strict) this way-

    use Data::Dumper; $Data::Dumper::Terse = 1; # No VARs. $Data::Dumper::Indent = 1; # Less indenting. my %what = ( foo => [ 1 .. 3 ], wacka => 1 ); print Dumper \%what; __END__ { 'wacka' => 1, 'foo' => [ 1, 2, 3 ] }