#!/usr/exp/bin/perl

$pat = '([2.2] ([2.76] [2.61] ([2.__] ))';
$pat =~ s/(\W)/\\$1/g;
$pat =~ s/__/(\\d+)/;

while (<>) {
        next if !/\[3\.4\]/;
        /$pat/;
        $number_of_queens = $1-51;
        last;
}

$separation = "--" x $number_of_queens . "\n";

$pat = '[2.85] ([2.2] ([2.76] [2.61] ([2.__] ))';
$pat =~ s/(\W)/\\$1/g;
$pat =~ s/__/(\\d+)/;

system "clear";
print $separation;
$empty_row = ". " x $number_of_queens . "\n";

while (<>) {
        next if !/\[3\.1\]/;
        while (s/$pat//o) {
                $row = $empty_row;
                substr ($row, ($1-52)*2,1) = 'Q';
                print $row;
        }
        print $separation;
}
