NAME
NetHack::Logfile - reading and writing NetHack's logfiles
VERSION
Version 0.01 released 04 Aug 07
SYNOPSIS
use NetHack::Logfile ':all';
my @scores = read_logfile("logfile");
@scores = sort { $b->{points} <=> $a->{points} } @scores;
$#scores = 1999;
write_logfile(\@scores, "high-scores");
my $game = parse_logline($scores[0]);
$game->{death} = 'ascended';
print make_logline($game), "\n";
FUNCTIONS
read_logfile [FILENAME] => ARRAY OF HASHREFS
Takes a file and parses it as a logfile. If any IO error occurs in reading the file, an exception is thrown. If any error occurs in parsing a logline, then an empty hash will be returned in its place.
The default value for the filename is "logfile".
parse_logline STRING => HASHREF
Takes a string and attempts to parse it as a logline. If a parse error occurs, undef
is returned. It's easy to fool this module with bogus role, race, gender, and alignment names, since these are not checked.
write_logfile ARRAYREF OF HASHREFS, FILENAME
Writes an logfile to FILENAME. If any IO error occurs, it will throw an exception. If any game is missing required keys, it will throw an exception.
Returns no useful value.
make_logline HASHREF => STRING
Takes a hashref and turns it into a logline. If not all keys are present (they must simply pass through defined
), then an exception will be thrown.
Field names
The field names are chosen for compatibility with the xlogfile format. I personally dislike many of them. C'est la vie.
- version
-
The version of NetHack. Current version is 3.4.3.
- points
-
The score when the game ended.
- dnum
-
The dungeon branch number where the game ended.
- deathlev
-
The dungeon level the game ended on.
- maxlvl
-
The deepest dungeon level the character explored.
- hp
-
The character's current HP when the game ended.
- maxhp
-
The character's maximum HP when the game ended.
- deaths
-
The number of times the character died. Ascension doesn't count as a death. Using up an amulet of life saving does.
- deathdate
-
The day (yyyymmdd) the game ended.
- birthdate
-
The day (yyyymmdd) the game began.
- uid
-
The user ID of the player.
- role
-
The character's role (three-letter form, so Wiz not Wizard).
- race
-
The character's race (three-letter form, so Dwa not Dwarf).
- gender
-
The character's ending gender (three-letter form, so Fem not Female).
- align
-
The character's ending align (three-letter form, so Cha not Chaotic).
- name
-
The name of the character.
- death
-
The way the character died. One hopes it is "ascension".
AUTHOR
Shawn M Moore, <sartak at gmail.com>
BUGS
No known bugs.
Please report any bugs through RT: email bug-nethack-logfile at rt.cpan.org
, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=NetHack-Logfile.
SUPPORT
You can find this documentation for this module with the perldoc command.
perldoc NetHack::Logfile
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
Thanks to the NetHack DevTeam for all their hard work.
Thanks NetHack, for kicking oh-so-much ass. Happy twentieth birthday!
COPYRIGHT & LICENSE
Copyright 2007 Shawn M Moore.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
7 POD Errors
The following errors were encountered while parsing the POD:
- Around line 188:
Expected text after =item, not a number
- Around line 192:
Expected text after =item, not a number
- Around line 196:
Expected text after =item, not a number
- Around line 200:
Expected text after =item, not a number
- Around line 204:
Expected text after =item, not a number
- Around line 208:
Expected text after =item, not a number
- Around line 212:
Expected text after =item, not a number