|
Hi
All,
I am trying to embed perl in my C application. I have read the perlembed doc - and it works up to a point. My app crashes whenever - (a) theres a syntax error (b) There's a missing or mis-spelled module specified in the script. I want to handle the error (compilation error or whatever, and pass the error message back to main). Here's a section of my code: int my_perl_parser( char *ptext, char *run ) { char *embedding[] = { "", run, "0" }; int retval = 0; PerlInterpreter *my_perl; my_perl = perl_alloc(); perl_construct( my_perl ); perl_parse(my_perl, xs_init, 3, embedding, NULL); perl_run(my_perl); perl_eval_pv( ptext, TRUE ); perl_destruct(my_perl); perl_free(my_perl); return retval; } int main(int argc, char **argv, char **env) { char sTest[128] = "" ; sprintf(sTest,"use Strict;\n \ use FakeModule;\n \ print 'Woohoo !! - I can use extensions!'") ; return my_perl_parser( sTest, "-e" ); } The crash always occurs (for the conditions specified above) on the perl_eval function call. Any suggestions as to what I am doing wrong ? Thanks in advance |
