Convert::AcrossLite - Convert binary AcrossLite puzzle files to text.
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"; }
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).
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'.
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');
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');
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;
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"; }
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"; }
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"; }
This method will parse the puzzle file by calling _parse_file.
This method returns file parse status: 0 if input file has not been parsed, 1 if input file has been parsed.
This method returns the number of rows in puzzle.
my $rows = $ac->get_rows;
This method returns the number of columns in puzzle.
my $columns = $ac->get_columns;
This method returns the puzzle solution.
my @solution = $ac->get_solution;
This method returns the puzzle solution diagram.
my @solution = $ac->get_diagram;
This method returns the puzzle title.
my $title = $ac->get_title;
This method returns the puzzle author.
my $author = $ac->get_author;
This method returns the puzzle copyright.
my $copyright = $ac->get_copyright;
This method returns the puzzle across clues.
my $across_clues = $ac->get_across_clues;
This method returns the puzzle down clues.
my $down_clues = $ac->get_down_clues;
You can find documentation for this module with the perldoc command.
perldoc Convert::AcrossLite
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Convert-AcrossLite
CPAN Ratings
http://cpanratings.perl.org/d/Convert-AcrossLite
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Convert-AcrossLite
Search CPAN
http://search.cpan.org/dist/Convert-AcrossLite
Changed eq '-' to ne '.' so filled-in puzzles will parse Patch from Ed Santiago
eq '-'
ne '.'
Doug Sparling <doug@dougsparling.com>
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.
To install Convert::AcrossLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convert::AcrossLite
CPAN shell
perl -MCPAN -e shell install Convert::AcrossLite
For more information on module installation, please visit the detailed CPAN module installation guide.