Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
The stupid question is the question not asked
 
PerlMonks  

Re: Syntax Error Checking

by Fastolfe (Vicar)
on Jan 01, 2001 at 17:01 UTC ( [id://49196]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Syntax Error Checking

Update: Bleh, all of these still fall prey to the BEGIN { ... } issue.. Anyone can still inject code that will be executed as the rest is compiled. I don't see any way around this.. You might just try s/BEGIN\s*{/BEGIN { die "No BEGIN block allowed"; }/g, but I'm not confident that that would catch all occurrences of BEGIN blocks (or END for that matter!), and it could easily hit something legitimate in the code body itself. Your best/only option may in fact be to try and use a Safe compartment.

The original message: Actually I just thought of a better way to do this:

sub test_code { my $code = shift; $code = 'die "OK\n"; ' . $code; eval $code; $@ eq "OK\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://49196]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.