in reply to Re: print arrays a(i), b(i,j) c(i,j)
in thread print arrays a(i), b(i,j) c(i,j)

Hmm, not quite. In fact, not at all. $; controls the symbol used as a subscript seperator for multi-dimensional hashes, not arrays. Perl arrays are more like lists - they are dynamiclly sized and can not by managed in the same way that fixed size C arrays can be.

To achieve multi-dimensional arrays in Perl you need to remember that a scalar can hold a reference to another object, for our purposes it can hold a reference to an array. So we implement multi-dimensional arrays by having an array of references to arrays.

A little syntactic sugar makes accessing such multi-dimensional arrays identical with the equivelent C syntax. $AoA[0][0] accesses the first element in the first row of the array @AoA. @AoA is really an array of references to arrays. The syntactic sugar saves writing the access as $AoA[0]->[0]; to dereference the first element of @AoA then index into the array referenced by that element. Take a look at the two @xxxx_cps arrays in the code sample in Re: print arrays a(i), b(i,j) c(i,j) to see how they are initialised and how elements in them are accessed


DWIM is Perl's answer to Gödel