/* compile with */ /* gcc -o monk monk.c `perl -MExtUtils::Embed -e ccopts -e ldopts` */ /* I tried this under Perl 5.6.0 and perl 5.005_3 */ # include # include # include # include void call_perl(); int main(int argc, char **argv, char **env) { /* That's OK: */ printf("Testing perl embedding\n"); call_perl(); /* But in a loop we leak as hell */ while (1) { call_perl(); sleep(1); } } void call_perl(void) { static PerlInterpreter *my_perl; char *embedding[] = { "", "-e", "0" }; my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, 3, embedding, NULL); perl_run(my_perl); eval_pv("print \"Perl Version: $]\\n\"",TRUE); perl_destruct(my_perl); perl_free(my_perl); }