FEN2diag.pl: a Perl script to convert FEN chess positions to human-readable diagrams

FEN2diag.pl 1.0
---------------

A Perl script for converting FEN position notation into a human-readable
8x8 chessboard diagram (or rather, a 10x10 diagram useable with the
Alpine typefaces, Linares/Hastings/Zurich).

It's not pretty but it's useful and it works. Developed after
discovering no obvious way to get diagrams into printable game
annotations on an Ubuntu system.

[I expect there is some alternative magic involving TeX but it was beyond
my skills and patience.]

How it works
------------
Run the script (open a command terminal and run "perl FEN2diag.pl". It
will ask you for a FEN string.

Copy positions in FEN notation from your chess database of choice
(ChessX in my case).

Paste the FEN string to the script prompt. It will produce a 10x10 grid
which can be pasted into your word processor of choice and an
appropriate typeface applied (I tested in Libre Office Write).

It will then ask you for another FEN string; if you're all done, "N" or
"n" at the prompt will end the programme:

FEN2DIAG chess position converter
=================================
N.B. To proceed, type or paste in FEN; to quit, press N or n
_
FEN string? =rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Diagram:
cuuuuuuuuC
(rhb1kgn4}
70p0p0p0p}
6wdwdwdwd}
5dwdwdwdw}
&wdwdwdwd}
3dwdwdwdw}
2P)P)P)P)}
%$NGQIBHR}a
v,./9EFJMV
FEN string? =n
Quitting programme: Ended at user's request.
Died at fen2diag.pl line 46, line 2.

Further prettifying possible
----------------------------
Processing files containing a series of FEN positions, one per line
Processing files with inline PGN FEN positions

DrDave, Exeter, May 2014.
chessnut at blueyonder.co.uk
============================

Appendix
--------

assigned symbols, Alpine typeface family

w light square
d dark square

p black pawn light square
r black rook light square
n black knight light square
b black bishop light square
q black queen light square
k black king light square

P white pawn light square
R white rook light square
N white knight light square
B white bishop light square
Q white queen light square
K white king light square

0 black pawn dark square
4 black rook dark square
h black knight dark square
g black bishop dark square
1 black queen dark square
i black king dark square

) white pawn dark square
$ white rook dark square
H white knight dark square
G white bishop dark square
! white queen dark square
I white king dark square

These typefaces also allow for a symbol-based border and
coordinates. I like co-ordinate labels left and bottom, and
side-to-move on the right, thus:

_
cuuuuuuuuC
(rhb1kgn4}
70p0p0p0p}
6wdwdwdwd}
5dwdwdwdw}
&wdwdwdwd}
3dwdwdwdw}
2P)P)P)P)}
%$NGQIBHR}a
v,./9EFJMV
_
A difficult position (Breyer).
_

The dark-squared symbols are assigned to characters whose keys sit above
and left on the QUERTY keyboard.

Attached files: 

Class: