in reply to Embedding perl in C.
Then for my script I used:#include <EXTERN.h> #include <perl.h> static PerlInterpreter *foo; main(int argc, char **argv, char **env) { char * args[] = { NULL, NULL}; args[0] = "geh\n"; foo = perl_alloc(); perl_construct(foo); perl_parse(foo, NULL, argc, argv, env); perl_call_argv("printme", G_DISCARD, args); perl_destruct(foo); perl_free(foo); }
The results:printme(); sub printme { print $_[0] };
So one of your problems was the last argument in perl_call_argv. You need to pass it an array of (char *) or a (char **) not just a single (char*). Also the last element in that char * array apparently needs to be NULL. So that is why I created a two element array, but only populated the first element.prompt% myperl script.pl geh
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Embedding perl in C.
by bitrush (Initiate) on Apr 25, 2000 at 19:08 UTC | |
|
Re: Re: Embedding perl in C.
by Anonymous Monk on Jul 14, 2001 at 01:09 UTC | |
by perlmonkey (Hermit) on Jul 30, 2001 at 22:41 UTC |