To learn how to embed perl in your C program, check out perlembed. Here is interp.c from the 5.8.0 docs:
This would then be compiled with a statement like#include <EXTERN.h> /* from the Perl distribution */ #include <perl.h> /* from the Perl distribution */ static PerlInterpreter *my_perl; /*** The Perl interpreter ***/ int main(int argc, char **argv, char **env) { my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); }
It is a bit of a learning curve to figure all this out, but people have embedded perl in their C programs as a built-in scripting language. It is less popular than one might think, however, because it is so easy for perl to interact with standalone C programs.% cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
-Mark
In reply to Re: Perl API with C
by kvale
in thread Perl API with C
by bakunin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |