Kenichi Ishigaki > Games-Sudoku-Component-0.02 > Games::Sudoku::Component::Controller::Loader

Download:
Games-Sudoku-Component-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Games::Sudoku::Component::Controller::Loader

SYNOPSIS ^

  require Games::Sudoku::Component::Controller::Loader;

  # Load from text
  my @cells = Games::Sudoku::Component::Controller::Loader->load(<<'EOT');
  4 . . . . 1
  2 1 . . 5 .
  3 5 1 2 6 .
  1 . . . 3 .
  6 . . 5 1 2
  5 . . . 4 6
  EOT

  # Or load from file
  my @cells = Games::Sudoku::Component::Controller::Loader->load(
    filename => 'file.txt',
  );

  # Or load from scalarref
  my $puzzle =<<'EOT';
  4 . . . . 1
  2 1 . . 5 .
  3 5 1 2 6 .
  1 . . . 3 .
  6 . . 5 1 2
  5 . . . 4 6
  EOT

  my @cells = Games::Sudoku::Component::Controller::Loader->load(\$puzzle);

  # When you finished loading, put the loaded data into a table.
  my $table = Games::Sudoku::Component::Table->new;
  foreach my $item (@cells) {
    $table->cell($item->row,$item->col)->value($item->value);
    $table->cell($item->row,$item->col)->lock if $item->value;
  }

DESCRIPTION ^

This module loads and parses puzzle data from file or scalar (reference) and returns an array of Games::Sudoku::Component::Table::Item objects.

METHODS ^

load (scalar or scalarref or hash or hashref)

Loads and parses puzzle data from file or scalar (reference), and then, returns an array of Games::Sudoku::Component::Table::Item objects.

Hash options are:

filename (or file, for short)

Filename for puzzle data.

scalar

Scalar of puzzle data.

scalarref

Scalar reference of puzzle data.

DATA STRUCTURE ^

Column separator is whitespaces. Row separator is line breaks. Other characters are treated as number, i.e. [^1-9] = 0.

SEE ALSO ^

Games::Sudoku::Component,
Games::Sudoku::Component::Controller,
Games::Sudoku::Component::Table

AUTHOR ^

Kenichi Ishigaki, <ishigaki@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2006 by Kenichi Ishigaki

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: