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