executing perl script (as char*, not file) in C and evaluating @ARGV

T

Torsten Mohr

Hi,

i'd like to write a C program that allocates a
PerlInterpreter* and executes a script that is
contained as a "char*" in the C program. I don't
want to load the script from a file.
The parameters that the C program gets should be
available in the perl script.

I looked through "perldoc perlembed" and "perlapi",
but i didn't find anything that really matches this.

"perl_parse" seems to be necessary to get @ARGV, but
if i don't pass {"", "-e", "0"} to it, it tries to
get input from stdin.

If i leave perl_parse away, the C program crashes.

Also, adding a line like "PERL_SYS_INIT3(&argc, &argv, &env);"
neither at the beginning nor before eval_pv(script_pointer, TRUE)
didn't help.


Has anybody got an example C program, that:

- executes a script that resides in memory
- makes @ARGV available to that script
- doesn't try to get input from stdin

I didn't find anything googling for it or in the source
tarball.


thanks for any hints,
Torsten.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top