When you start writing the C/C++ functions that you want to be able to access from within Perl, you need to use the XS() macro:
XS( FunctionName )
The XS() macro declares the function as a Perl function. The parameter passed in will be the function name that will be mapped in the bootstrap function (see the section “The Bootstrap Function” later in this chapter).
Really, this is quite easy to do. Whenever you are creating a function that will be called directly from a Perl script, you just declare the function using the XS() macro. This will guarantee that the function can communicate with Perl.
After you have declared your function, you need to set up the Perl variables that are needed by many of Perl’s macros. ...