Perl uses several variable types in its internal representation to achieve the flexibility that is needed for its external types: scalars, (SVs) arrays, (AVs) hashes (HVs) and code blocks. (CVs)
The module Devel::Peek allows us to examine how Perl types are repesented internally. The field names produced by Devel::Peek can be easily turned into macros which allow us to get and set the values of the fields from C.
The key files from the Perl source tree which deal with Perl's internal variables are sv.c, av.c and hv.c; the documentation in the associated header files (sv.h, av.h and hv.h) is extremely helpful for understanding how to deal with Perl's internal variables.