X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlembed.pod;h=36da54f7fe3318255e8facd1292c4ff2090f1631;hb=7360c6b444ea6e19b6583f9530f845bee19c7921;hp=2466531255a3e2159c022b56233db11a7cc17632;hpb=1c5b513e3fd8bc7a5a38ca94832b9e848ef0301d;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlembed.pod b/pod/perlembed.pod index 2466531..36da54f 100644 --- a/pod/perlembed.pod +++ b/pod/perlembed.pod @@ -196,11 +196,20 @@ version of I containing the essentials of embedding: Notice that we don't use the C pointer. Normally handed to C as its final argument, C here is replaced by -C, which means that the current environment will be used. The macros -PERL_SYS_INIT3() and PERL_SYS_TERM() provide system-specific tune up -of the C runtime environment necessary to run Perl interpreters; since -PERL_SYS_INIT3() may change C, it may be more appropriate to provide -C as an argument to perl_parse(). +C, which means that the current environment will be used. + +The macros PERL_SYS_INIT3() and PERL_SYS_TERM() provide system-specific +tune up of the C runtime environment necessary to run Perl interpreters; +they should only be called once regardless of how many interpreters you +create or destroy. Call PERL_SYS_INIT3() before you create your first +interpreter, and PERL_SYS_TERM() after you free your last interpreter. + +Since PERL_SYS_INIT3() may change C, it may be more appropriate to +provide C as an argument to perl_parse(). + +Also notice that no matter what arguments you pass to perl_parse(), +PERL_SYS_INIT3() must be invoked on the C main() argc, argv and env and +only once. Now compile this program (I'll call it I) into an executable: @@ -325,15 +334,15 @@ the first, a C from the second, and a C from the third. /** Treat $a as an integer **/ eval_pv("$a = 3; $a **= 2", TRUE); - printf("a = %d\n", SvIV(get_sv("a", FALSE))); + printf("a = %d\n", SvIV(get_sv("a", 0))); /** Treat $a as a float **/ eval_pv("$a = 3.14; $a **= 2", TRUE); - printf("a = %f\n", SvNV(get_sv("a", FALSE))); + printf("a = %f\n", SvNV(get_sv("a", 0))); /** Treat $a as a string **/ eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE); - printf("a = %s\n", SvPV_nolen(get_sv("a", FALSE))); + printf("a = %s\n", SvPV_nolen(get_sv("a", 0))); perl_destruct(my_perl); perl_free(my_perl); @@ -457,7 +466,7 @@ been wrapped here): retval = my_eval_sv(command, TRUE); SvREFCNT_dec(command); - *string = get_sv("string", FALSE); + *string = get_sv("string", 0); return SvIV(retval); } @@ -480,7 +489,7 @@ been wrapped here): my_eval_sv(command, TRUE); SvREFCNT_dec(command); - *match_list = get_av("array", FALSE); + *match_list = get_av("array", 0); num_matches = av_len(*match_list) + 1; /** assume $[ is 0 **/ return num_matches;