How to Write a Perl Extension
Before understanding how to create an extension, you need to familiarize yourself with a couple of rather important topics, the first of which is how Perl handles variables.
The Guts of Perl Variables
A Perl scalar variable is really a memory structure known as an SV (scalar variable). When your script creates a new scalar variable, a memory structure is allocated, and the value is assigned to it. If you ever access the value in a different context (such as accessing an integer as a string), the SV will convert itself to the context value. If you create a variable, assigning it the value 10, for example, SV is created containing the integer value 10. If you then try to print out the value, the SV will have to convert ...