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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.