in reply to Re^2: Dangling Pointer::perl referrence
in thread Dangling Pointer::perl referrence

Different to C there are global variables that spring into existence the moment you refer to them. So when perl executes $ref = \@array; in your second example, @array is a new global (but empty) variable that has nothing in common with the 'my @array' variable except for the name.

If you had a line 'use warnings;' at the beginning of your script (a practice very recommended), you would have seen the following warning: "Name "main::array" used only once: possible typo at ./t7.pl line 6". Ok, not that easy to decipher, but once you know that global variables are living in name spaces, the default one being called 'main::', you would have a clue about what went wrong

If you also had a line 'use strict;' at the beginning of your script (a practice very recommended for any script larger than a few lines) your script would have aborted at the compilation stage with error messages about global variables.