NAME
Chess::NumberMoves - Perl extension for numbering chess moves
SYNOPSIS
INITIAL FILE LACKS MOVE NUMBERS
Because I typed them in from a chess book but didn't feel like entering the move numbers:
[Event "?"]
[Site "Los Angeles"]
[EventDate "1963"]
[White "Benko"]
[Black "Najdorf"]
[Result "*"]
d4 Nf6
c4 c5
d5 d6
Nc3 g6
e4 Bg7
Be2 O-O
Nf3 e5
Bg5 h6
Bh4 g5
Bg3 Nh5
h4 Nf4
hxg5 hxg5
Bf1 Bg4
Qc2 Bxf3
gxf3 Nd7
O-O-O Re8
Bh3 Nxh3
Rxh3 Nf8
Rdh1 Ng6
Nd1 Rc8
Ne3 Rc7
Nf5 Rf8
Qd1 f6
f4 exf4
Qh5 Ne5
Qh7 Kf7
Qxg7+ Ke8
Qxf8+ Kxf8
Rh8+ Kf7
Rxd8
=head2 THEN WE NUMBER THE FILE
use Chess::NumberMoves;
my $numbered = Chess::NumberMoves::from_file('benko-najdorf.pgn');
print $numbered;
[Event "?"]
[Site "Los Angeles"]
[EventDate "1963"]
[White "Benko"]
[Black "Najdorf"]
[Result "*"]
1. d4 Nf6
2. c4 c5
3. d5 d6
4. Nc3 g6
5. e4 Bg7
6. Be2 O-O
7. Nf3 e5
8. Bg5 h6
9. Bh4 g5
10. Bg3 Nh5
11. h4 Nf4
12. hxg5 hxg5
13. Bf1 Bg4
14. Qc2 Bxf3
15. gxf3 Nd7
16. O-O-O Re8
17. Bh3 Nxh3
18. Rxh3 Nf8
19. Rdh1 Ng6
20. Nd1 Rc8
21. Ne3 Rc7
22. Nf5 Rf8
23. Qd1 f6
24. f4 exf4
25. Qh5 Ne5
26. Qh7 Kf7
27. Qxg7+ Ke8
28. Qxf8+ Kxf8
29. Rh8+ Kf7
30. Rxd8
ABSTRACT
This is a program for numbering a file consisting of chess moves listed
two per line.
DESCRIPTION
Any line in the file which matches the regexp:
/^[A-Z]/
has a line number prepended to it.
I wrote this because I was typing moves from a chess game listed in a book ("Simple Chess" by Michael Stean --- it rocks you should buy it!) but felt it was not a good use of my time to keep entering numbers.
And presto-chango a little bit of Perl and here ya have it.
CONVENIENCE SCRIPT
A convenience script pgo2pgn
is included which takes a file with .pgo
extension and converts it to a pgn file, saving it with a .pgn
extension. The conversion is to take a file which contains a pair of moves on each line and number the lines.
EXPORT
None by default.
SEE ALSO
A better way to do this:
Chess::PGN::Parse on CPAN by Giuseppe Maxia
The perl-chess mailing list:
perl-chess-subscribe@yahoogroups.com
to subscribe
http://www.yahoogroups.com/group/perl-chess
to read the archives.
AUTHOR
Terrence Brannon, tbone@cpan.org
COPYRIGHT AND LICENSE
Copyright 2004 by Terrence Brannon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.