gideondsouza has asked for the wisdom of the Perl Monks concerning the following question:
So I have a little 'executor.pl' script that looks like this:
## executor.pl use Safe; if($ARGV[0]) { my $code = $ARGV[0]; my $compartment = new Safe; $compartment->deny(qw(:base_io... MANY OP CODES....)); $compartment->permit(qw(print say pack unpack require caller)); ##I want to pass something into the STDIN for the $code reval- +ed my $result = $compartment->reval($code); if ($@) { print "Unsafe code detected: $@"; } }
And I do this to invoke executor.pl :
open(FILE,"perl executor.pl '$code' 2>&1 |") my @output=<FILE>; my $resp = join('',@output);
Question: Is there a way I can pass some argument into the code being reval-ed as STDIN ?. So essentially I can reval some code and then pass it some known arg to its STDIN
Please don't worry, this isn't any production code. I'm just doing this as a learning/curiosity exercise
Back to
Seekers of Perl Wisdom