Subject: [LON-CAPA-dev] [Fwd: eval inside of reval inside of modperl, and $@]

From: Gerd Kortemeyer <[email-masked]>
Date: Mon, 08 Jul 2002 12:31:44 -0400

I had also sent this to the modperl mailing list, but got no replies ...
$@%@#!!!

Subject: eval inside of reval inside of modperl, and $@
From: Gerd Kortemeyer <[email-masked]>
To: [email-masked]
Date: Sat, 06 Jul 2002 13:31:07 -0400

Hi,

I might be totally confusing myself, but I do have problems with the $@
variable inside of a Safe compartment inside of an Apache modperl
module.

The following subroutine returns "Oops Illegal division by zero ..."
when called from a standalone program, and "No problem" when called
inside a modperl module:

sub initsheet {
    my $safeeval = new Safe(shift);
    $safeeval->permit("entereval");
    $safeeval->share('$@');

my $stuff=(<<'ENDSTUFF');
my $a=5;
my $b=0;

my $c=eval '$a/$b';
if ($@) {
    return 'Oops '.$@;
} else {
    return 'No problem!';
}
ENDSTUFF

    return $safeeval->reval($stuff);
}

In spite of the division by zero in the $c=eval ... statement, $@ is not
set when inside of modperl.

BTW, the $safeeval->share('$@') was necessary to get this to work at
all, even as standalone. Now, maybe I need to share something else when
inside modperl?

Anybody any ideas what's going on?

THANKS!

- Gerd.