Hi ! Is there a nice way to catch compile/parse errors from a perl script in embedded perl ? the perl script is in a string, I want to see if it compiles correctly and in the case there are errors, make them available to the embedding application. I tried something similar to
// code contains the perl code (char *) // errmsg should be filled with the compile erros PerlInterpreter *myPerlCompile; /*** The Perl interpreter ***/ char *largv[] = { "", "-c", "-e", code, NULL }; int largc=4; int errFnd; initPerlInterp(); myPerlCompile = perl_alloc(); perl_construct(myPerlCompile); //PL_exit_flags |= PERL_EXIT_DESTRUCT_END; errFnd=perl_parse(myPerlCompile, xs_init, largc, largv, (char **)NULL) +; sprintf(errmsg, "%s", SvPV_nolen(ERRSV));
but this does not work (errFnd is filled in case of errors, but errmsg stays empty) I got the impression that there certainly is a better approach for this... thanx !

In reply to embedded perl: check for compile errors without executing by lorius

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.