All multi-dimensional data structures are implemented as arrays of references |
for $i (1..10) { |
@list = somefunc($i); # grab a list labelled by $i |
# Compute the number of elements in @list: |
$LoL[$i] = scalar @list; |
# Create a fresh 2D array for each $i: |
$LoL2D[$i] = [ @list ]; # use array constructor [ ] |
} # End for loop |
my(@list) = somefunc($i); # my() creates a fresh instance each time |
$LoL2D[$i] = \@list; # also works but is perhaps less clear |