splitpod broken in 5.004_01
[p5sagit/p5-mst-13.2.git] / pod / perlcall.pod
index 0bfd142..f90e09f 100644 (file)
@@ -356,7 +356,7 @@ As mentioned above, you can determine the context of the currently
 executing subroutine in Perl with I<wantarray>.  The equivalent test
 can be made in C by using the C<GIMME_V> macro, which returns
 C<G_ARRAY> if you have been called in an array context, C<G_SCALAR> if
-in a a scalar context, or C<G_VOID> if in a void context (i.e. the
+in a scalar context, or C<G_VOID> if in a void context (i.e. the
 return value will not be used).  An older version of this macro is
 called C<GIMME>; in a void context it returns C<G_SCALAR> instead of
 C<G_VOID>.  An example of using the C<GIMME_V> macro is shown in
@@ -1915,6 +1915,25 @@ refers to the last.
 
 =back
 
+=head2 Creating and calling an anonymous subroutine in C
+
+As we've already shown, L<perl_call_sv> can be used to invoke an
+anonymous subroutine.  However, our example showed how Perl script
+invoking an XSUB to preform this operation.  Let's see how it can be
+done inside our C code:
+
+ ...
+
+ SV *cvrv = perl_eval_pv("sub { print 'You will not find me cluttering any namespace!' }", TRUE);
+
+ ...
+
+ perl_call_sv(cvrv, G_VOID|G_NOARGS);
+
+L<perlguts/perl_eval_pv> is used to compile the anonymous subroutine, which
+will be the return value as well.  Once this code reference is in hand, it
+can be mixed in with all the previous examples we've shown.
+
 =head1 SEE ALSO
 
 L<perlxs>, L<perlguts>, L<perlembed>
@@ -1931,4 +1950,4 @@ and Larry Wall.
 
 =head1 DATE
 
-Version 1.2, 16th Jan 1996
+Version 1.3, 14th Apr 1997