In a sense, perl (the C program) is a good example of embedding Perl
(the language), so I'll demonstrate embedding with I<miniperlmain.c>,
-included in the source distribution. Here's a bastardized, nonportable
+included in the source distribution. Here's a bastardized, non-portable
version of I<miniperlmain.c> containing the essentials of embedding:
#include <EXTERN.h> /* from the Perl distribution */
a = Just Another Perl Hacker
In the example above, we've created a global variable to temporarily
-store the computed value of our eval'd expression. It is also
+store the computed value of our eval'ed expression. It is also
possible and in most cases a better strategy to fetch the return value
from I<eval_pv()> instead. Example:
I32 match(SV *string, char *pattern)
{
- SV *command = NEWSV(1099, 0), *retval;
+ SV *command = newSV(0), *retval;
STRLEN n_a;
sv_setpvf(command, "my $string = '%s'; $string =~ %s",
I32 substitute(SV **string, char *pattern)
{
- SV *command = NEWSV(1099, 0), *retval;
+ SV *command = newSV(0), *retval;
STRLEN n_a;
sv_setpvf(command, "$string = '%s'; ($string =~ %s)",
I32 matches(SV *string, char *pattern, AV **match_list)
{
- SV *command = NEWSV(1099, 0);
+ SV *command = newSV(0);
I32 num_matches;
STRLEN n_a;
perl_parse(my_perl, NULL, 3, embedding, NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
- text = NEWSV(1099,0);
+ text = newSV(0);
sv_setpv(text, "When he is at a convenience store and the "
"bill comes to some amount like 76 cents, Maynard is "
"aware that there is something he *should* do, something "
not be initialized correctly between consecutive runs and your
application may crash.
+See also L<perlxs/Thread-aware system interfaces>.
+
Using C<-Dusethreads -Duseithreads> rather than C<-Dusemultiplicity>
is more appropriate if you intend to run multiple interpreters
concurrently in different threads, because it enables support for