Ricardo SIGNES > Games-Crossword-Puzzle-0.002 > Games::Crossword::Puzzle

Download:
Games-Crossword-Puzzle-0.002.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.002   Source   Latest Release: Games-Crossword-Puzzle-0.003

NAME ^

Games::Crossword::Puzzle - six letters for "reusable unit of code"

VERSION ^

version 0.002

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 methods 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.

note

This method returns the puzzle's "note," if any.

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.)

(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.)

AUTHOR ^

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: