Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Executing code block in memory

by kennethk (Abbot)
on Aug 08, 2012 at 22:18 UTC ( #986376=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Executing code block in memory
in thread Executing code block in memory

A modified version of your sample that does what I mean:

#!/usr/bin/perl -w use strict; use URI::Escape; use HTML::Entities; use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; print header; my $file; if(param('test')){ my $code = param('test'); $code = uri_unescape($code); $code = encode_entities($code); open STDERR, '>&STDOUT'; eval $code; print $@ if $@; }

No need to create external, temporary files. There are some potential messy issues in there, but this is good enough for rough cut.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re^3: Executing code block in memory
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2015-07-04 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls