tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:

I was playing around with this really neat intro to ruby where you learn ruby by typing into the browser. I guess they somehow rigged it up that the browser is a shell.

I think this is a really neat trick and a great piece of propaganda. Wondering if anything similar exists for perl, and if not, if it is theoretically possible to do so or if there is some reason it's hard to do.

  • Comment on Can you execute perl code from a browser?

Replies are listed 'Best First'.
Re: Can you execute perl code from a browser?
by Fletch (Bishop) on Jun 05, 2006 at 23:23 UTC

    There was discussion of implementing something similar about a month ago (see Hands-on of Perl by Web). Might contact the OP of that thread and see if they've gotten anything going.

Re: Can you execute perl code from a browser?
by bpphillips (Friar) on Jun 06, 2006 at 02:44 UTC
    It would probably take a bit of wrapping but Devel::ebug::HTTP might be a good starting point for this. I played with it a bit last fall or summer and it looked pretty interesting (it's built on top of Catalyst so there are naturally tons of dependencies that must be present in order to install it). Devel::ebug::HTTP is an extention of Devel::ebug which is an attempt to refactor the stock perl debugger. It provides a really slick (AJAX) web interface that (IIRC) even allows you to step backwards in your script. I only dabbled with it for a couple of days before letting it sit long enough that I've not yet come back to it.

    It might be worth a look to see if it would be customizable enough to act more like an interactive shell rather than a full-featured debugger.

    -- Brian
Re: Can you execute perl code from a browser?
by leocharre (Priest) on Jun 06, 2006 at 15:43 UTC

    To do this with any level of safety ; you would have to know more perl then John Galt to figure how to check the code for bad mojo.
    This is super sketchy. You are basically blindfolding yourself, walking into the bronx with your pants to your ankles and your hands cuffed, with a sign on your back that says "please *#6!%^^ me in the -*# #^#_ and take my $$$$"

    I would suggest to set up a sepparate box appart from your server to do this. Make a user called "beatme", "l3pp3r", or "thepoor"- and take away all the priviliges but running perl on that account. Maybe set up a sepparate error log for that user.

    This box would be sent the text, and send back output. Hey, maybe you could have your own tail -f /var/log/httpd/error_log that refreshes - that would be cool.

    Maybe people would have to send you some info before they can use it? Like their ssn and a copy of their driver's license? :)