

my @board;
my $N = 4;

RANK:
while (@board < $N) {
 FILE:
  for ($file=0; $file < $N; $file++) {
    for ($r = 0; $r < @board; $r++) {
      next FILE if $board->[$r]        == $file;
      next FILE if $board->[$r]+$r     == $file+@board;
      next FILE if $board->[$r]+@board == $file+$r;
    }
    push @board, $file;
    next RANK;
  }
}

print "@board\n";
