Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: running string as perl script and pass into STDIN programatically

by gideondsouza (Pilgrim)
on Feb 17, 2013 at 08:10 UTC ( #1019116=note: print w/replies, xml ) Need Help??


in reply to Re: running string as perl script and pass into STDIN programatically
in thread running string as perl script and pass into STDIN programatically

So I'll just start from the use case :)

I'm developing a little pet project project here : www.tryperl.com

I'm a linux/perl beginner (touched it for the first time 3 months ago) but I want to really learn it well, so this is my learning project

My problem:
Given C (=perl code in a string) and A(=argument) I want to evaluate C and just return STDOUT and STDERR (the output of the program, or an error if it occurred). I also want to do this within a timeout.

So : my ($stdout, $err) = eval_perl($program, $args); What would be the simplest way of writing eval_perl with good performance?

I did just have a loong discussion on irc #perl and plan on building better security processes later on, but I don't know enough right now. I run the code in a EC2 vm now so I'm pretty safe. So I just want to stick to the above use case.

I also have a list of things I've tried and my issues here on stackoverflow. No answers yet :( I tried capture::tiny and also App:EvalServer I'm told executes one liners, I want to exec the whole some_script.pl program at once.

  • Comment on Re^2: running string as perl script and pass into STDIN programatically

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019116]
help
Chatterbox?
[1nickt]: my $x = $aohoaoh->[0]->{' foo'}->[0]->{'bar' }; should work
[thepkd]: not indexing
[thepkd]: getting data out of the ds
[choroba]: it depends. Give more details, please
[thepkd]: i used a series of {}'s but it dont work
[choroba]: You need square brackets for arrays
[GotToBTru]: you can certainly construct a single expression to access any part of the data structure, without using temp variables. but you might make it easier on yourself and any other poor soul who has to understand your code if you do
[thepkd]: to dereference i mean
LanX .oO( oh tempz, oh moretz)
[thepkd]: @GotToBTru Sure. But.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2016-12-06 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.