continuing from previous foil
-
$LoL2D[$i] = \@list; # does create a 2D array but \@list is same location each time and so $LoL2D[$i][$j] will give same answer whatever $i chosen with final @list returned being accessed each time
-
$LoL2D[$i] = [ @list ]; # finally creates intended 2D array as array constructor [ ] will create a fresh reference for each $i
|
} # End for $i (1..10)
-
my(@list) = somefunc($i); # my creates a fresh instance each time
-
$LoL2D[$i] = \@list; # also works but is perhaps less clear
|
Note my() can occur as here inside any block { } and not just at start of subroutine and defines variables local to block
|