(x,y) -1,1 | 1,1 ----------+---------- <-- origin (0,0) -1,-1 | 1,-1 #### use strict; my (@pp_grid, @pn_grid, @nn_grid, @np_grid, @input); #INPUT push @pp_grid, [ @input ] for @input; push @pn_grid, [ @input ] for @input; push @nn_grid, [ @input ] for @input; push @np_grid, [ @input ] for @input; @pp_grid = ( [ qw( a b c d ) ], [ qw( e f g h ) ], [ qw( i j k l ) ], [ qw( m n o p ) ], ); @pn_grid = ( [ qw( q r s t ) ], [ qw( u v w x ) ], [ qw( y z 1 2 ) ], [ qw( 3 4 5 6 ) ], ); @nn_grid = ( [ qw( A B C D ) ], [ qw( E F G H ) ], [ qw( I J K L ) ], [ qw( M N O P ) ], ); @np_grid = ( [ qw( Q S T U ) ], [ qw( V W X Y ) ], [ qw( Z 7 8 9 ) ], [ qw( 0 ? ! & ) ], ); #OUTPUT print "pp_grid:\n"; print "@$_\n" for @pp_grid; print "\n"; print "np_grid:\n"; print "@$_\n" for @np_grid; print "\n"; print "nn_grid:\n"; print "@$_\n" for @nn_grid; print "\n"; print "pn_grid:\n"; print "@$_\n" for @pn_grid; print " and here is 1,-1: $pn_grid[1][1]\n"; print " and here is 1,1: $pp_grid[1][1]\n"; print " and here is -1,1: $np_grid[1][1]\n"; print " and here is -1,-1: $nn_grid[1][1]\n";