use strict; use warnings; use Data::Dumper; open ( OHA, ">c:/printoutLIST1.txt" ) or die ("could not open file. &!" ); my @lite; my ($x, $y); # $lite[0][0] = x value # $lite[0][1] = y value # $lite[0][2] = (used?) 0 = not used, 1 = used # $lite[0][3] = x location in grid (lower left corner) # $lite[0][4] = y location in grid (lower left corner) # $lite[0][5] = (rotated?) 0 = not rotated, 1 = rotated $lite[0][0] = 2; $lite[0][1] = 5; $lite[0][2] = 0; $lite[0][3] = 999; $lite[0][4] = 999; $lite[0][5] = 0; $lite[1][0] = 4; $lite[1][1] = 3; $lite[1][2] = 0; $lite[1][3] = 999; $lite[1][4] = 999; $lite[2][0] = 1; $lite[2][1] = 4; $lite[2][2] = 0; $lite[2][3] = 999; $lite[2][4] = 999; $lite[3][0] = 4; $lite[3][1] = 1; $lite[3][2] = 0; $lite[3][3] = 999; $lite[3][4] = 999; my @line; for my $i (0..2*$#lite) { $line[$i] = 0; } for my $j (0..$#lite) { # loop through all possibilities for my $k (0..$#line) { # check if x is already in the list if ($lite[$j][0] == $line[$k]) { # if x is in list-get out goto OUT; } } for my $l (0..$#line) { # find where to place x if ($line[$l] == 0) { $x = $l; goto OUT2; } } OUT2: $line[$x] = $lite[$j][0]; OUT: for my $m (0..$#line) { # check if y is already in list if ($lite[$j][1] == $line[$m]) { # if y is in list-get out goto OUT3; } } for my $n (0..$#line) { # find where to place y if ($line[$n] == 0) { $y = $n; goto OUT4; } } OUT4: $line[$y] = $lite[$j][1]; OUT3: } for my $p (0..$#line) { for my $o (0..$#line) { select OHA; print "LINE $o [$line[$o]]\n"; select STDOUT; }