NAME
Games::Go::AGA::Parse::Round - Parses lines from an AGA Tournament Round file
VERSION
version 0.042
SYNOPSIS
use Games::Go::AGA::Parse::Round;
my $parser = Games::Go::AGA::Parse::Round->new;
my %line_info = $parser->parse_line($line); # where $line is a line from
# the rounds file
DESCRIPTION
Games::Go::AGA::Parse::Round can parse lines of information from an AGA tournament rounds file. The file contains a list of games that were played during the round.
METHODS
- my $parser = Games::Go::AGA::Parse::Round->new;
-
Creates a parser object.
- my $parser = $parser->filename( ['new_name'])
-
Get/set a filename (used in error messages)
- my $file_handle = $parser->filename( [$new_file_handle ])
-
Get/set a file handle (used in error messages)
- my %line_info = $parser->parse_line( $line );
- my %line_info = $parser->parse( $line );
-
$line is a line of text from a round.tde format file. Returns the same as as_hash below.
- %as_hash = $parser->as_hash()
-
Retuns the parsed line as a hash. Missing fields will be empty strings (''). The hash keys are
( white_id => string containing the white ID, black_id => string containing the black ID, result => a single character containg either 'w', 'b', or '?', handicap => a number containing the number of handicap stones, komi => a number containing the komi, comment => string following the '#' comment marker (if any) )
If $line is empty, the hash will also be empty. If $line contains only a comment, the hash will contain only the comment.
Note that BYES are not explicitly listed in a round.tde file. Instead, they must be found by a process of elimination with respect to the players in the registration file.
In scalar context, returns a reference to the hash.
- @as_array = $parser->as_array()
-
Retuns the parsed line as an array. Missing fields will be empty strings (''). The order is:
( white_id black_id result handicap komi comment )
In scalar context, returns a reference to the array.
- $field_by_name = $parser-> < name >
-
Individual fields may be set or retrieved by name. E.g:
$handicap = $parser->handicap . . . $parser->komi(6.5);
OPTIONS
Options to the ->new method are:
These are not required to create a parser, but if supplied, error exceptions will include more useful information.
AUTHOR
Reid Augustin <reid@hellosix.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Reid Augustin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.