++ed by:
1 non-PAUSE user
Author image Ricardo SIGNES 😄


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


version 0.003


  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.



  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 <rjbs@cpan.org>


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.