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

{ my @array = 'element'; } $ref = \@array; print "$ref\n";

That doesn't compile, at least not under use strict; which you should be using. The reason is the second @array is a completely different variable than the first. It's package variable $main::array, aka a global variable. Global variables, by definition and by design, don't get freed before the program exits (without taking some intentional action to remove it from the symbol table). Think of extern int a; in a .h.

Now where it's referring too? There is no such variable ... means no such memory location?

Global variables get created simply by using them. By taking a reference to previously non-existant @main::array (2nd snippet) or @main::arr (3rd snippet), they get created. Well, technically, they already existed in those snippets because the parser created them when it noticed they will be used. The following code peeks at the symbol table where package variables reside:

>perl -E"say *array{ARRAY}||0;" 0 >perl -E"say *array{ARRAY}||0; @array; say *array{ARRAY}||0;" ARRAY(0x182a24c) ARRAY(0x182a24c) >perl -E"say *array{ARRAY}||0; @{'array'}; say *array{ARRAY}||0;" 0 ARRAY(0x238b24)

The parser created @main::array when it compiled @array
The runtime created @main::array when it evaluated @{"array"}