Chess::PGN::Filter - Perl extension for converting PGN files to other formats.
#!/usr/bin/perl # use strict; use warnings; use Chess::PGN::Filter;
if ($ARGV[0]) { filter(source => $ARGV[0],filtertype => 'XML'); }
OR
#!/usr/bin/perl # use strict; use warnings; use Chess::PGN::Filter;
if ($ARGV[0]) { my %substitutions = ( hsmyers => 'Myers, Hugh S (ID)' );
my @exclude = qw(
WhiteElo
BlackElo
EventDate
);
filter(
source => $ARGV[0],
filtertype => 'TEXT',
substitutions => \%substitutions,
nags => 'yes',
exclude => \@exclude,
);
}
OR
#!/usr/bin/perl # use strict; use warnings; use Chess::PGN::Filter;
if ($ARGV[0]) { filter( source => $ARGV[0], filtertype => 'DOM', ); }
This is a typical text in one side, different text out the otherside filter module. There are as of this writing, the following supported choices:
$VAR1 = { 'Tags' => { 'Site' => 'Boise (ID)', 'Event' => 'Cabin Fever Open', 'Round' => '1', 'ECO' => '?', 'Date' => '1997.??.??', 'White' => 'Barrett Curtis', 'Black' => 'Myers Hugh S', 'Result' => '1-0' }, 'Gametext' => [ { 'Movenumber' => '1', 'Epd' => 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3', 'Movetext' => 'e4' }, { 'Movenumber' => '2', 'Epd' => 'rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6', 'Movetext' => 'd5' }, { 'Movenumber' => '3', 'Epd' => 'rnbqkbnr/ppp1pppp/8/3pP3/8/8/PPPP1PPP/RNBQKBNR b KQkq -', 'Movetext' => 'e5' }, { 'Movenumber' => '4', 'Comment' => 'Playing ...Bf5 before closing the c8-h3 diagonal has some positive features.', 'Epd' => 'rnbqkbnr/ppp2ppp/4p3/3pP3/8/8/PPPP1PPP/RNBQKBNR w KQkq -', 'Movetext' => 'e6' }, { 'Movenumber' => '5', 'Epd' => 'rnbqkbnr/ppp2ppp/4p3/3pP3/3P4/8/PPP2PPP/RNBQKBNR b KQkq d3', 'Movetext' => 'd4' }, { 'Movenumber' => '6', 'Comment' => 'Time to think like a Frenchie - c7-c5!', 'Epd' => 'r1bqkbnr/ppp2ppp/2n1p3/3pP3/3P4/8/PPP2PPP/RNBQKBNR w KQkq -', 'Movetext' => 'Nc6', 'Rav' => [ { 'Movenumber' => '6', 'Epd' => 'rnbqkbnr/pp3ppp/4p3/2ppP3/3P4/8/PPP2PPP/RNBQKBNR w KQkq c6', 'Movetext' => 'c5' } ] }, . . . { 'Movenumber' => '29', 'Comment' => ' (Bxe5) Black could still kick for a while if he had played ...Bxe5.', 'Epd' => 'r1bq1rk1/2p1npb1/2n1p2P/pp1pP1p1/3P2P1/2P4Q/PP2BP2/RNB1K2R b KQ -', 'Movetext' => 'h6' } ] };
Briefly, the DOM is a multiply nested data structure of hashes and arrays. In a sort of outline form, it more or less follows this schematic:
The 'extra' comments have not yet been implemented. See the TODO list.
Owing to a dearth of imagination, there is but one exported routine in the module:
There are however, a small host of known keys for parameter_hash and they are as follows:
This is actually a hash reference where the hash reffered to has the form of (text_to_change => text_to_change_to). For instance:
my %substitutions = ( hsmyers => 'Myers, Hugh S (ID)' );
as used in the SYNOPSIS example would expand my user name into a full version for any tag the former might occur in.
This is an array reference where the referent has the form of (tag_to_exclude_1..tag_to_exclude_n), i.e.:
my @exclude = qw( WhiteElo BlackElo EventDate );
again, as used in the SYNOPSIS example, this would eliminate the 'WhiteElo', 'BlackElo' and 'EventDate' tags from the .pgn file being processed.
Possible values are:
Following list shows font name, font designer. They are available from http://www.enpassant.dk/chess/fonteng.htm
Note -- not all fonts support all combinations of 'border', 'corner' and 'legend'. No warnings or errors will be generated by unsupported options, you get the best a font can do, no more!
None known; Unknown? Of course, though I try to be neat...
Hugh S. Myers