version 1.6, 2000/09/19 18:05:21
|
version 1.9, 2000/10/30 20:05:19
|
Line 6 sub evaluate {
|
Line 6 sub evaluate {
|
# gerd's old method interpolates unset vars |
# gerd's old method interpolates unset vars |
# $safeeval->reval('return qq('.$expression.');'); |
# $safeeval->reval('return qq('.$expression.');'); |
unless (defined $expression) { return ''; } |
unless (defined $expression) { return ''; } |
$safeeval->reval('$_=\''.$expression.'\';'); |
my $result = ''; |
$safeeval->reval('{'.$decls.'$_=~s/(\$\{?[A-Za-z]\w*\}?)/(defined(eval($1))?eval($1):$1)/ge;}'); |
$@=''; |
$safeeval->reval('return $_;'); |
$safeeval->reval('$_=q|'.$expression.'|;'); |
|
if ($@ eq '') { |
|
$safeeval->reval('{'.$decls.'$_=~s/(\$[A-Za-z]\w*)/(defined(eval($1))?eval($1):$1)/ge;}'); |
|
if ($@ eq '') { |
|
$result = $safeeval->reval('return $_;'); |
|
} else { |
|
&Apache::lonxml::error("substituion on:$expression:with:$decls:caused"); |
|
} |
|
} else { |
|
&Apache::lonxml::error("defining:$expression:caused"); |
|
} |
|
if ($@ ne '') {&Apache::lonxml::error($@);} |
|
return $result |
} |
} |
|
|
sub run { |
sub run { |
my ($code,$safeeval) = @_; |
my ($code,$safeeval) = @_; |
# print "inside run\n"; |
# print "inside run\n"; |
$safeeval->reval($code); |
$@=''; |
|
my $result=$safeeval->reval($code); |
|
if ($@ ne '') { |
|
&Apache::lonxml::error(":$code:caused"); |
|
&Apache::lonxml::error($@); |
|
} |
|
return $result; |
} |
} |
|
|
1; |
1; |