#!/usr/bin/perl -w
use Safe;
print "Content-type: text/html\n\n";
my %params = (
key1 => 'value1',
key2 => 'value2',
key3 => 'value3',
);
# Run as a normal eval
my $script = 'return $params{\'key1\'}';
my $ret = eval($script); warn $@ if $@;
print "ret=$ret
";
# Now run the script in a safe compartment
my $compartment = new Safe();
$compartment->share('%params');
$ret = $compartment->reval($script);
print "ret=$ret
";
####
ret=value1
ret=