use Math::MatrixReal; $mat = Math::MatrixReal->new_from_rows( [[1, 2, 3], [4, 5, 6], [7, 8, 9]] ); for my $i (2..3) { # 1 first index for my $j (2..3) { print $mat->element($i, $j), " "; } print "\n"; } # print "5 6 # 8 9"