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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing argument into STDIN inside safe.pm reval
by 7stud (Deacon) on Feb 12, 2013 at 02:10 UTC | |
by gideondsouza (Pilgrim) on Feb 12, 2013 at 05:20 UTC | |
by Dallaylaen (Chaplain) on Feb 12, 2013 at 10:53 UTC | |
by 7stud (Deacon) on Feb 12, 2013 at 18:06 UTC | |
by Dallaylaen (Chaplain) on Feb 14, 2013 at 21:14 UTC | |
Re: Passing argument into STDIN inside safe.pm reval
by 7stud (Deacon) on Feb 11, 2013 at 19:22 UTC | |
Re: Passing argument into STDIN inside safe.pm reval
by 7stud (Deacon) on Feb 12, 2013 at 00:12 UTC |
Back to
Seekers of Perl Wisdom