in reply to pointer memory and dynamic memory

For a quick start on how Perls memory management and memory layout work, see Perlguts illustrated. Your language indicates that you are coming from a C background - the Perl data types like reference and array don't match up directly with C pointers and arrays - there is magic happening inbetween so that the reference counting etc. works.

As a very short start to understand Perlguts Illustrated, a scalar is represented mostly by an SV, and an array by an AV.