in reply to unable to eval dumped hash

To get rid of $VAR1 I set $Data::Dumper::Terse = 1; (also relevant $Data::Dumper::Varname).

The idiom I use for eval'ing is:

my $result = eval { $hash }; if( $@ || ! $result ){ die "error eval: $@" }

For "undumping" there is also Data::Undump which claims to be secure, I guess that's in reference to the eval? But it's not clear to me.

Replies are listed 'Best First'.
Re^2: unable to eval dumped hash
by jcb (Parson) on Apr 29, 2020 at 01:15 UTC

    There is also the Safe module for evaluating untrusted input while limiting possible damage.

        That way requires a LOT of trust in the safety of Safe.

        Perhaps so, but I do not expect that trust to be misplaced. Tcl uses the same concept for its "safe" interpreters and I do not recall any exploits in either that Tcl facility or Perl's Safe. Do you have a counterexample?

        The safe way of saving and restoring data is to handle it as data, not as code.

        I agree that that is the preferred option, but interface constraints from existing systems can interfere.