in reply to Exactly HOW eval works (with Data::Dumper)

It's pretty much in the documentation for eval, but I try to explain a bit nonetheless.

There are two completely different usages of eval. The first:

eval { # code here that might throw exceptions # this is the form that you described }

And the second:

my $string = '4 + 5'; my $answer = eval $string;

This second form is what you need. It takes a string, and compiles and runs it like a little Perl program.

There are other serialization formats that you might want to use instead of Data::Dumper like Storable, YAML, JSON and XML. They have the advantage that you don't have to eval your code, which is a security risk if you don't trust your data source.

Replies are listed 'Best First'.
Re^2: Exactly HOW eval works (with Data::Dumper)
by whakka (Hermit) on Dec 12, 2007 at 18:18 UTC
    Ah thanks, I wasn't quite getting that second distinction, and after looking at the output again it makes perfect sense.