X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlcall.pod;h=f90e09f2384ba682fdc48143ebdffa57f6751559;hb=40d50c580e6c25e8b1b8fe1baed51a3d15af70f9;hp=0bfd142cb3807f587dae2387bc9a73f7e59c6146;hpb=4a6725af9146bd7faaa10aa5429ff009d393fd6d;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlcall.pod b/pod/perlcall.pod index 0bfd142..f90e09f 100644 --- a/pod/perlcall.pod +++ b/pod/perlcall.pod @@ -356,7 +356,7 @@ As mentioned above, you can determine the context of the currently executing subroutine in Perl with I. The equivalent test can be made in C by using the C macro, which returns C if you have been called in an array context, C if -in a a scalar context, or C if in a void context (i.e. the +in a scalar context, or C if in a void context (i.e. the return value will not be used). An older version of this macro is called C; in a void context it returns C instead of C. An example of using the C 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 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 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, L, L @@ -1931,4 +1950,4 @@ and Larry Wall. =head1 DATE -Version 1.2, 16th Jan 1996 +Version 1.3, 14th Apr 1997