Games::Crossword::Puzzle - six letters for "reusable unit of code"
version 0.004
my $puzzle = Games::Crossword::Puzzle->from_file('nyt-sunday.puz'); for my $row ($puzzle->rows) { for my $cell (@$row) { die "Nope, not completed properly" if $cell->value and (not $cell->guess) || $cell->guess ne $cell->value; } }
The .PUZ file format is used by many crossword programs and, more importantly, is offered by many newspapers. It servers as both a puzzle and a "saved game," storing the grid, the answers, the clues, and guesses.
Games::Crossword::Puzzle reads .PUZ files and produces Games::Crossword::Puzzle objects.
A puzzle is a rectangular grid of Games::Crossword::Puzzle::Cell objects.
This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
my $puzzle = Games::Crossword::Puzzle->from_file($filename);
This method reads in a puzzle file and returns a puzzle object. It will raise an exception if the file does not appear to be a valid puzzle file.
These methods return the height and width of the puzzle grid.
This method returns a list of arrayrefs, each representing one row of the grid. Each arrayref is populated with Games::Crossword::Puzzle::Cell objects.
my $cell = $puzzle->cell($number);
This method returns the cell with the given number. Not every cell is numbered! Only cells that have clues are numbered.
This method will raise an exception if an invalid cell is requested.
This method returns the puzzle's title.
This method returns the puzzle's author.
This method returns the puzzle's copyright information.
This method returns the puzzle's "note," if any.
While there is some basic checking that the input file really is a puzzle file, the checksums aren't checked, which could lead to loading an invalid file. I may get around to fixing this in the future.
Josh Myer is a nerd and reverse engineered the PUZ format enough for this module to be written. I used his notes, found here: http://www.joshisanerd.com/puz/
Daniel Jalkut, an internet-famous blogger, hyped up a forthcoming product for a while, finally revealing that it was Black Ink, a nice crossword program for OS X. I like crosswords, but I didn't want to spend $25 on it, so I had a look into the weird "PUZ" format it used. I wrote this module as phase one in producing my own free crossword software, possibly a PUZ-to-DHTML sort of thing. (Warning: I have been known to quit after phase one.)
(My loving wife later bought me a copy of Black Ink, so I didn't have much reason to keep working on this, but I did finally add some basic rebus cell parsing six years later.)
Ricardo SIGNES <cpan@semiotic.systems>
Ricardo SIGNES <rjbs@codesimply.com>
Ricardo Signes <rjbs@semiotic.systems>
This software is copyright (c) 2007 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Games::Crossword::Puzzle, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Crossword::Puzzle
CPAN shell
perl -MCPAN -e shell install Games::Crossword::Puzzle
For more information on module installation, please visit the detailed CPAN module installation guide.