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 ...

Get Win32 Perl Programming: The Standard Extensions, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.