The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Convert::AcrossLite - Convert binary AcrossLite puzzle files to text.

SYNOPSIS

  use Convert::AcrossLite;

  my $ac = Convert::AcrossLite->new();
  $ac->in_file('/home/doug/puzzles/Easy.puz');
  $ac->out_file('/home/doug/puzzles/Easy.txt');
  $ac->puz2text;

  or

  use Convert::AcrossLite;

  my $ac = Convert::AcrossLite->new();
  $ac->in_file('/home/doug/puzzles/Easy.puz');
  my $text = $ac->puz2text;

  or

  use Convert::AcrossLite;

  my $ac = Convert::AcrossLite->new();
  $ac->in_file('/home/doug/puzzles/Easy.puz');
  my $ac->parse_file;
  my $title = $ac->get_title;
  my $author = $ac->get_author;
  my $copyright = $ac->get_copyright;
  my @solution = $ac->get_solution;
  my @diagram = $ac->get_diagram;
  my $across_clues = $ac->get_across_clues;
  my $down_clues = $ac->get_down_clues;

  or

  use Convert::AcrossLite;

  my $ac = Convert::AcrossLite->new();
  $ac->in_file('/home/doug/puzzles/Easy.puz');

  my($across_hashref, $down_hashref) = get_across_down;

  my %across= %$across_hashref;
  foreach my $key (sort { $a <=> $b } keys %across) {
      print "Direction: $across{$key}{direction}\n";
      print "Clue Number: $across{$key}{clue_number}\n";
      print "Row: $across{$key}{row}\n";
      print "Col: $across{$key}{column}\n";
      print "Clue: $across{$key}{clue}\n";
      print "Solution: $across{$key}{solution}\n";
      print "Length: $across{$key}{length}\n\n";
  }

  my %down= %$down_hashref;
  foreach my $key (sort { $a <=> $b } keys %down) {
      print "Direction: $down{$key}{direction}\n";
      print "Clue Number: $down{$key}{clue_number}\n";
      print "Row: $down{$key}{row}\n";
      print "Col: $down{$key}{column}\n";
      print "Clue: $down{$key}{clue}\n";
      print "Solution: $down{$key}{solution}\n";
      print "Length: $down{$key}{length}\n\n";
  }

DESCRIPTION

Convert::AcrossLite is used to convert binary AcrossLite puzzle files to text.

Convert::AcrossLite is loosely based on the C program written by Bob Newell (http://www.gtoal.com/wordgames/gene/AcrossLite).

CONSTRUCTOR

new

This is the contructor. You can pass the full path to the puzzle input file.

  my $ac = Convert::AcrossLite->new(in_file => '/home/doug/puzzles/Easy.puz');

The default value is 'Default.puz'.

METHODS

in_file

This method returns the current puzzle input path/filename.

  my $in_filename = $ac->in_file;

You may also set the puzzle input file by passing the path/filename.

  $ac->in_file('/home/doug/puzzles/Easy.puz');

out_file

This method returns the current puzzle output path/filename.

  my $out_filename = $ac->out_file;

You may also set the puzzle output file by passing the path/filename.

  $ac->out_file('/home/doug/puzzles/Easy.txt');

puz2text

This method will produce a basic text file in the same format as the easy.txt file provided with AcrossLite. This method will read the input file set by in_file and write to the file set by out_file.

  $ac->puz2text;

If out_file is not set, then the text is returned.

  print $ac->puz2text;

  or

  my $text = $ac->puz2text;

get_across_down

This method will get all the information needed to build any type of output you may need(some info is set by parse_file): direction (across/down), clue_number, clue, solution, solution length, grid row and column. This method will return two hash references (across and down).

  my($across_hashref, $down_hashref) = get_across_down;

  my %across= %$across_hashref;
  foreach my $key (sort { $a <=> $b } keys %across) {
      print "Direction: $across{$key}{direction}\n";
      print "Clue Number: $across{$key}{clue_number}\n";
      print "Row: $across{$key}{row}\n";
      print "Col: $across{$key}{column}\n";
      print "Clue: $across{$key}{clue}\n";
      print "Solution: $across{$key}{solution}\n";
      print "Length: $across{$key}{length}\n\n";
  }

  my %down= %$down_hashref;
  foreach my $key (sort { $a <=> $b } keys %down) {
      print "Direction: $down{$key}{direction}\n";
      print "Clue Number: $down{$key}{clue_number}\n";
      print "Row: $down{$key}{row}\n";
      print "Col: $down{$key}{column}\n";
      print "Clue: $down{$key}{clue}\n";
      print "Solution: $down{$key}{solution}\n";
      print "Length: $down{$key}{length}\n\n";
  }

get_across

This method will return all the across information (some info is set by parse_file): direction, clue_number, clue, solution, solution length, grid row and column. This method will return a hash reference.

  my $across_hashref = get_across;
 
  my %across= %$across_hashref;
  foreach my $key (sort { $a <=> $b } keys %across) {
      print "Direction: $across{$key}{direction}\n";
      print "Clue Number: $across{$key}{clue_number}\n";
      print "Row: $across{$key}{row}\n";
      print "Col: $across{$key}{column}\n";
      print "Clue: $across{$key}{clue}\n";
      print "Solution: $across{$key}{solution}\n";
      print "Length: $across{$key}{length}\n\n";
  }

get_down

This method will return all the down information (some info is set by parse_file): direction, clue_number, clue, solution, solution length, grid row and column. This method will return a hash reference.

  my $down_hashref = get_down;

  my %down= %$down_hashref;
  foreach my $key (sort { $a <=> $b } keys %down) {
      print "Direction: $down{$key}{direction}\n";
      print "Clue Number: $down{$key}{clue_number}\n";
      print "Row: $down{$key}{row}\n";
      print "Col: $down{$key}{column}\n";
      print "Clue: $down{$key}{clue}\n";
      print "Solution: $down{$key}{solution}\n";
      print "Length: $down{$key}{length}\n\n";
  }

parse_file

This method will parse the puzzle file by calling _parse_file.

is_parsed

This method returns file parse status: 0 if input file has not been parsed, 1 if input file has been parsed.

get_rows

This method returns the number of rows in puzzle.

  my $rows = $ac->get_rows;

get_columns

This method returns the number of columns in puzzle.

  my $columns = $ac->get_columns;

get_solution

This method returns the puzzle solution.

  my @solution = $ac->get_solution;

get_diagram

This method returns the puzzle solution diagram.

  my @solution = $ac->get_diagram;

get_title

This method returns the puzzle title.

  my $title = $ac->get_title;

get_author

This method returns the puzzle author.

  my $author = $ac->get_author;

This method returns the puzzle copyright.

  my $copyright = $ac->get_copyright;

get_across_clues

This method returns the puzzle across clues.

  my $across_clues = $ac->get_across_clues;

get_down_clues

This method returns the puzzle down clues.

  my $down_clues = $ac->get_down_clues;

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Convert::AcrossLite

You can also look for information at:

ACKNOWLEDGEMENTS

Changed eq '-' to ne '.' so filled-in puzzles will parse Patch from Ed Santiago

AUTHOR

Doug Sparling <doug@dougsparling.com>

COPYRIGHT

Copyright (c) 2006 Douglas Sparling. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.