Let\'s say I have a text file created using Data::Dumper, along the lines of:
my $x = [ { foo => \'bar\', asdf => undef }, 0, -4, [ [] ] ];
As Rich says, you probably don't want to use Data::Dumper for persistence, but rather something like Storable.
However, to answer the question asked... IIRC, Data::Dumper doesn't declare your variables to be my
, so are you doing that yourself somehow?
To be able to eval
the data back in, the variable needs to not be my
within the eval. If your text file contained this:
$x = [ { foo => 'bar', asdf => undef }, 0, -4, [ [] ] ];
Then this would work:
my $vars;
{
undef $/;
$vars = ;
}
my $x;
eval $vars;
print $x;