darkdiver has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I would like to add a script into my C program (just embed it) and execute it through libperl. How can I do that? Simple eval has limitations on IO operations, etc. So it does not fit.

It's necessary to keep a script in the same binary (not in separate file).

I mean this:

const char script[] = "Here is my big script with function 'exec_it()'"; static PerlInterpreter *my_perl; my_perl = perl_alloc(); perl_construct(my_perl);
# here should be something to load the script into the interpreter. So this is the question...
perl_call_pv("exec_it", G_DISCARD);

Replies are listed 'Best First'.
Re: Embedding perl script into C program
by ikegami (Patriarch) on Mar 17, 2010 at 22:04 UTC
    See perlembed.

    Simple eval has limitations on IO operations, etc. So it does not fit.

    eval imposes no limits.