eval

The argument is parsed and executed as if it were a Perl program.

my $ret = eval $perl_code;
if( $@)
{
    print "error: eval returned $@\n";
}

The value returned from eval is the value of the last expression evaluated.

eval traps otherwise-fatal errors:

#!/usr/bin/perl

$a = 1; 
$b = 0; 
eval
{
    $c = $a / $b;
}; 
if( $@)
{
    print "error: eval returned $@\n";
}



Subsections