sub print2DArray { for my $i (0 .. $#_) { for my $j (0 .. $#{$_[$i]}){ print $_[$i][$j]," "; } print "\n"; } }