Figure 20.1 shows the various components of a running Perl system. Shaded rectangles represent data structures, some of which can have multiple instances in a program. The source code can also be partitioned roughly along these lines.
Figure 20-1. Snapshot of a running system
The box “Perl object API” in Figure 20.1 represents the API to manipulate all internal data structures, such as variables, symbol tables, stacks, and resources such as files and sockets.
We saw in Chapter 3, that the term “variable” refers to a name-value pair. In this chapter, we will look at the API to manipulate the different types of values and to optionally bind them to names. A value can be one of the following:
|SV: Scalar value|
|AV: Array value|
|HV: Hash value|
|CV: Code value|
|GV: Glob value (or typeglob)|
|RV: Reference value|
An SV can further be classified as an IV (integer value), PV (string
value), or NV (double). The abbreviations are part of a uniform
naming convention, so you can easily guess the intent of a function
newSViv, for example.
These value types provide a simple API, resize themselves automatically, and follow simple memory management protocols. For this reason, most Perl internal data structures such as stacks and symbol tables are also implemented in terms of these values.
Symbol tables are plain old HVs, whose keys are identifier names ...