Let's say I have a text file created using Data::Dumper, along the lines of:
my $x = [ { foo => 'bar', asdf => undef }, 0, -4, [ [] ] ];
I'd like to read that file back in and get $x back. I tried this:
my $vars;
{
undef $/;
$vars = <FILE>;
}
eval $vars;
But it didn't seem to work -- $x not only isn't defined, when I try to use it I get a warning that "Global symbol $x requires explicit package name."
What's the right way to do this? (And yes, I know it's ugly. It's a quick utility script, not e.g., a life-support system)