`sub valid {
my $spot = substr($grid_h, $_[0]*$size+$_[1], 1);
return 1 if $spot eq $_[2];
return if $spot ne '_';
return if index(substr($grid_h, $_[0] * $size, $size), $_[2]) >= 0;
return if index(substr($grid_v, $_[1] * $size, $size), $_[2]) >= 0;
return 1;
}
$re = qr/
(?:
(?(?{ !valid(0, 0, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '1')
+; }) |
(?(?{ !valid(0, 0, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '2')
+; }) |
(?(?{ !valid(0, 0, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '3')
+; }) |
(?(?{ !valid(0, 0, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '4')
+; }) |
(?(?{ !valid(0, 0, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '5')
+; }) |
(?(?{ !valid(0, 0, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '6')
+; }) |
(?(?{ !valid(0, 0, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '7')
+; }) |
(?(?{ !valid(0, 0, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '8')
+; }) |
(?(?{ !valid(0, 0, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 0, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 0, 1, '9')
+; })
)
(?:
(?(?{ !valid(0, 1, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '1')
+; }) |
(?(?{ !valid(0, 1, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '2')
+; }) |
(?(?{ !valid(0, 1, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '3')
+; }) |
(?(?{ !valid(0, 1, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '4')
+; }) |
(?(?{ !valid(0, 1, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '5')
+; }) |
(?(?{ !valid(0, 1, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '6')
+; }) |
(?(?{ !valid(0, 1, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '7')
+; }) |
(?(?{ !valid(0, 1, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '8')
+; }) |
(?(?{ !valid(0, 1, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 1, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 9, 1, '9')
+; })
)
(?:
(?(?{ !valid(0, 2, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '1'
+); }) |
(?(?{ !valid(0, 2, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '2'
+); }) |
(?(?{ !valid(0, 2, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '3'
+); }) |
(?(?{ !valid(0, 2, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '4'
+); }) |
(?(?{ !valid(0, 2, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '5'
+); }) |
(?(?{ !valid(0, 2, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '6'
+); }) |
(?(?{ !valid(0, 2, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '7'
+); }) |
(?(?{ !valid(0, 2, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '8'
+); }) |
(?(?{ !valid(0, 2, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 2, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 18, 1, '9'
+); })
)
.
.
.
(?:
(?(?{ !valid(8, 6, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '1
+'); }) |
(?(?{ !valid(8, 6, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '2
+'); }) |
(?(?{ !valid(8, 6, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '3
+'); }) |
(?(?{ !valid(8, 6, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '4
+'); }) |
(?(?{ !valid(8, 6, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '5
+'); }) |
(?(?{ !valid(8, 6, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '6
+'); }) |
(?(?{ !valid(8, 6, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '7
+'); }) |
(?(?{ !valid(8, 6, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '8
+'); }) |
(?(?{ !valid(8, 6, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 78, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 62, 1, '9
+'); })
)
(?:
(?(?{ !valid(8, 7, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '1
+'); }) |
(?(?{ !valid(8, 7, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '2
+'); }) |
(?(?{ !valid(8, 7, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '3
+'); }) |
(?(?{ !valid(8, 7, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '4
+'); }) |
(?(?{ !valid(8, 7, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '5
+'); }) |
(?(?{ !valid(8, 7, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '6
+'); }) |
(?(?{ !valid(8, 7, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '7
+'); }) |
(?(?{ !valid(8, 7, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '8
+'); }) |
(?(?{ !valid(8, 7, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 79, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 71, 1, '9
+'); })
)
(?:
(?(?{ !valid(8, 8, '1') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '1'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '1
+'); }) |
(?(?{ !valid(8, 8, '2') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '2'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '2
+'); }) |
(?(?{ !valid(8, 8, '3') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '3'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '3
+'); }) |
(?(?{ !valid(8, 8, '4') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '4'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '4
+'); }) |
(?(?{ !valid(8, 8, '5') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '5'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '5
+'); }) |
(?(?{ !valid(8, 8, '6') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '6'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '6
+'); }) |
(?(?{ !valid(8, 8, '7') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '7'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '7
+'); }) |
(?(?{ !valid(8, 8, '8') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '8'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '8
+'); }) |
(?(?{ !valid(8, 8, '9') })x)(?{ local $grid_h = $grid_h; substr($gr
+id_h, 80, 1, '9'); local $grid_v = $grid_v; substr($grid_v, 80, 1, '9
+'); })
)
(?{ $match_grid = $grid_h })
/x;
`

Comment onRe: The craziest RegExes you ever createdDownloadCode