NAME
Games::Go::AGA::Parse::TDList - Parses lines from an AGA TDLISTlist
VERSION
version 0.042
SYNOPSIS
use Games::Go::Parse::TDList;
my
$parser
= Games::Go::AGA::Parse::TDList->new;
while
(
my
$line
= <
$tdlist_fh
>) {
my
$hash
=
$parser
->parse(
$line
);
# ref to a hash
...
}
DESCRIPTION
A parser to break out and return fields of a line from an AGA TDListN.txt file. The fields are usually:
last_name
first_name
id
membership
rank
date
club
state
extra
but some fields could be empty ('').
Note that the rank field may be either rank format (3K, 4d, etc) or a numerical rating (from -100 to +20 with a gap from -1 to +1). Rank format implies less certainty in the accuracy of the rank. The Rank_to_Rating function in Games::Go::AGA::Parse::Utils can be used to force the numerical format.
METHODS
- $parser = Games::Go::AGA::Parse::TDList->new;
-
Creates a new parser object.
- $parser = $parser->filename( ['new_name'])
-
Get/set a filename (used in error messages)
- $file_handle = $parser->filename( [$new_file_handle ])
-
Get/set a file handle (used in error messages)
- %result_hash = $parser->parse_line('a TDListN line')
- %result_hash = $parser->parse()
-
Parses a single line from the TDListN.txt file and returns a hash with the fields as listed in as_hash. Calling this function removes any field results from previous lines.
- %as_hash = $parser->as_hash()
-
Retuns the parsed line as a hash. Missing fields will be empty strings (''). The hash keys are
(
last_name
=>
'last name of player'
,
first_name
=>
'first name of player'
,
id
=>
'player ID'
,
membership
=>
'AGA membership type (if any)'
,
rank
=>
'player'
s rank or rating',
date
=>
'date player'
s membership is valid
until
',
club
=>
'club player usually plays at'
,
state
=>
'state player lives in'
,
extra
=>
'any extra stuff'
,
)
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:
(
last_name
first_name
id
membership
rank
date
club
state
extra
)
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:
$last_name
=
$parser
->last_name
. . .
$parser
->rank(
'4d'
);
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.