my $cmd = '1/0'; eval $cmd; if ($@) { print "$cmd gives: $@\n" } 1/0 gives: Illegal division by zero at (eval 1) line 2.