djerius has asked for the wisdom of the Perl Monks concerning the following question:
And here's what it spits out:use feature qw[ say ]; use Safe; # works here say "Hello!"; my $cft = Safe->new; # allow all opcodes $cft->deny_only(); # doesn't work here (expected result) $cft->reval( 'say "Hello Again!"' ); # explicit load of feature, but doesn't work (unexpected result) $cft->reval( 'use feature qw[ say ]; say "Hello Again! 2"' );
Does anyone have any experience with this?Hello! String found where operator expected at (eval 5) line 1, near "say "He +llo Again!"" (Do you need to predeclare say?) String found where operator expected at (eval 7) line 1, near "say "He +llo Again! 2"" (Do you need to predeclare say?)
Thanks,
Diab
Update: I should be clearer about the question:
How does one enable features in a Safe compartment? My example code seems to indicate that a simple use feature doesn't do anything within the compartment. Am I mising something?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using features in a Safe compartment
by muzakfetch (Scribe) on Mar 21, 2011 at 23:21 UTC | |
by djerius (Beadle) on Mar 22, 2011 at 04:09 UTC | |
|
Re: using features in a Safe compartment
by locked_user sundialsvc4 (Abbot) on Mar 23, 2011 at 16:03 UTC |