Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I just realized that this may be quite easy to implement using existing features. Where 'this' is to run 'eval' in order to check for syntax errors while preventing any code from being run, even if a form of 'BEGIN' is used in the code.

I believe that there are ways to hook Perl's "run loop". So the steps would be:

  1. fork to get a new Perl interpreter instance (will work even on Windows)
  2. In the child instance, hook the "run loop"
  3. Call "eval $code"
  4. The run loop hook would allow Perl opnodes to execute until the 'eval' op hit
  5. If any other ops try to run after that, die
  6. CORE::exit to destroy the Perl interpreter that might have had some functions defined that we don't want to call by accident

Unfortunately, I don't know how you hook Perl's run-loop. And there might be complications to overcome when getting into the details of making this work.

But I can see real value in such a feature.

Disabling the running of code may be as simple as just defining "sub DB::sub" and "sub DB::DB" (you probably need to put your code that calls eval() into 'package DB' so it wouldn't be subject to the debugging hooks). But you can also look at what Enbugger does to enable debugging or what Devel::NYTProf does to profile opcodes.

- tye        

In reply to Re: How to do perl -c inside perl? (op-hook) by tye
in thread How to do perl -c inside perl? by rockyb

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2018-01-23 00:54 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (238 votes). Check out past polls.