And my conclusion from Auditing BEGIN blocks? is that it won't be possible to do this until perl6 when the grammar can be subverted.
Added On further thought - what you can do is use the Safe module and then go some varying lengths to protect yourself from side effects. I might prepend CHECK { return undef $@; } to the string to be tested. It's guaranteed to run before anything else in the block except a BEGIN block. You then just test $@ as normal to see if it's got a value. Also, when using Safe either be sure it's the fixed version or that you create a new compartment each time you want to test. Also use one the ARLM tricks from the perlipc page. If you get caught in an infinite or absurdly long loop you'll still get execution back. I don't think you can do this and actually be paranoid because the code could also allocate a whole lot of RAM or do something else to violate a user limit. My OS (OpenBSD) has limits preventing user processes from going hog wild so that's the sort of user-limit I'm thinking of.
If you want to hear more then respond.
Seeking Green geeks in Minnesota
In reply to Re^2: run-time syntax checking
by diotalevi
in thread run-time syntax checking
by Pardus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |