How Perl Handles Variables
Suppose that instead of using a static variable for your bit array, you want to pass it a Perl scalar and let the program store its data there. To do so, you need to know a little about how Perl stores its data internally.
All Perl scalar variables are represented by the type SV defined in the perl.h file. The definition of this type is
struct sv { void* sv_any; /* pointer to something */ U32 sv_refcnt; /* how many references to us */ U32 sv_flags; /* what we are */ }; typedef struct sv SV;
The sv_any field points to the data held in the scalar. This can be a Perl string (called a byte array by C programmers) or a reference to a hash, array, code, scalar, or typeglob.
The sv_refcnt is a reference count used by Perl ...
Get Perl for C Programmers 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.