NAME
Games::Crossword::Puzzle - six letters for "reusable unit of code"
VERSION
version 0.001
$Id: /my/cs/projects/Games-Crossword-Puzzle/trunk/lib/Games/Crossword/Puzzle.pm 31483 2007-04-27T13:49:35.406241Z rjbs $
SYNOPSIS
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;
}
}
DESCRIPTION
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.
METHODS
from_file
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.
height
width
These method return the height and width of the puzzle grid.
rows
This method returns a list of arrayrefs, each representing one row of the grid. Each arrayref is populated with Games::Crossword::Puzzle::Cell objects.
cell
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.
title
This method returns the puzzle's title.
author
This method returns the puzzle's author.
copyright
This method returns the puzzle's copyright information.
AUTHOR
Ricardo SIGNES, <rjbs at cpan.org>
COPYRIGHT & LICENSE
Copyright 2007 Ricardo SIGNES, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
CAVEATS
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.
THANKS
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/
SECRET ORIGINS
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.)
COPYRIGHT & LICENSE
Copyright 2007 Ricardo SIGNES, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.