smack has asked for the wisdom of the Perl Monks concerning the following question:
However, I am unable to access prewritten perl functions. Here is the code I have been attempting to get to work:#include <stdafx.h> #include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; int main (int argc, char **argv, char **env) { STRLEN n_a; char *embedding[] = { "", "-e", "0" }; my_perl = perl_alloc(); perl_construct( my_perl ); perl_parse(my_perl, NULL, 3, embedding, NULL); perl_run(my_perl); /** Treat $a as an integer **/ eval_pv("$a = 3; $a **= 2", TRUE); printf("a = %d\n", SvIV(get_sv("a", FALSE))); /** Treat $a as a float **/ eval_pv("$a = 3.14; $a **= 2", TRUE); printf("a = %f\n", SvNV(get_sv("a", FALSE))); /** Treat $a as a string **/ eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", T +RUE); printf("a = %s\n", SvPV(get_sv("a", FALSE), n_a)); perl_destruct(my_perl); perl_free(my_perl); return 0; }
#include "stdafx.h" #include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; static void call_PrintUID() { dSP ; PUSHMARK(SP) ; call_pv("PrintUID", G_DISCARD|G_NOARGS) ; } int main (int argc, char **argv, char **env) { char *embedding[] = { "", "printuid.pl" }; my_perl = perl_alloc(); perl_construct( my_perl ); perl_parse(my_perl, NULL, 3, embedding, NULL); perl_run(my_perl); call_PrintUID(); perl_destruct(my_perl); perl_free(my_perl); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Embedding perl into a win32 console application
by Anonymous Monk on Oct 07, 2004 at 21:45 UTC | |
|
Re: Embedding perl into a win32 console application
by kutsu (Priest) on Oct 07, 2004 at 21:52 UTC | |
|
Re: Embedding perl into a win32 console application
by gmpassos (Priest) on Oct 08, 2004 at 01:42 UTC |