I have the following three assignments, of which the second one looks non-standard:
my $realRef = [1, 2, 3];
my @nonRef = [4, 5, 6];
my $nonRef = [7, 8, 9];
The second one should really be the following instead:
my @nonRef = (4, 5, 6);
When printing, all three variables contain array references and especially the same named variables only differing in @ and $ don't share the same data or overwrite each other.
Ref: ARRAY(0x1fd6a8); $VAR1 = [
1,
2,
3
];
Ref: ARRAY(0x6445d8); $VAR1 = [
4,
5,
6
];
Ref: ARRAY(0x644740); $VAR1 = [
7,
8,
9
];
Why is @nonRefcontaining an array reference at all? Is that stored in $nonRef of the symbol table entry for nonRef or something like that? And why do values of @nonRef and $nonRef don't overlap? Aren't both referencing the same symbol table entry only with different slots, ARRAY vs. SCALAR? Because both store references in the end, I would have expected that the same symbol table entry with the slot SCALAR is used.
Thanks!