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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.