my @product = matrix_multiply( $matrix1[0], $matrix1[1], $matrix1[2], $matrix2[0], $matrix2[1], $matrix2[2] ); # @product has only one element. # $product[0] is a ref to the resulting matrix