eval "\$$arrayname{\$key} = 1";

*****

while (<>) { eval; print $@; }

*****

# make divide-by-zero non-fatal

eval { $answer = $a / $b; }; warn $@ if $@;



# same thing, but less efficient

eval '$answer = $a / $b'; warn $@ if $@;



# a compile-time error (not trapped)

eval { $answer = };



# a run-time error

eval '$answer =';  # sets $@

*****

eval $x;          # CASE 1

eval "$x";        # CASE 2



eval '$x';        # CASE 3

eval { $x };      # CASE 4



eval "\$$x++";    # CASE 5

$$x++;            # CASE 6

*****

#!/usr/bin/perl

$whatever = shift;



eval <<'EndOfEval';  $start = __LINE__;

   .

   .           # your ad here

   .

EndOfEval



# Cleanup



unlink "/tmp/myfile$$";

$@ && ($@ =~ s/\(eval \d+\) at line (\d+)/$0 .

    " line " . ($1+$start)/e, die $@);

exit 0;

*****

eval $prog . '#' . ++$seq;

