Hi!
First of all, "reval" only evaluates the code and then returns the value. So in this case, the following will work:
use warnings;
use strict;
use Safe;
use feature qw{say};
say "Hello!";
my $cft = Safe->new;
$cft->deny_only();
my $ret = $dft->reval(qq{return "Hello Again!"}, undef);
say $ret;
So using the "say" doesn't work because it evaluates to nothing, and returns nothing. In fact, I was kind of surprised that it didn't at least return "1" since say should return "true". But who knows.
Update: something else just occurred to me. Safe is not going to evaluate the "use" or in this case what I tried below. It evaluates the entire script, doesn't recognize the "say" keyword and throws the error. It never *executes* the use or the require/import.
my $unsafe = qq|
require feature;
feature->import( qw{say switch} );
say "Hope this works";
return "I did what you said";
|;
# explicit load of feature, but doesn't work (unexpected result)
$ret = $cft->reval( $unsafe, undef );
HTH,
Tyler.