#!/usr/bin/perl -wnl # A Perl script for printing all unique NetHack deaths incurred & their # frequencies, based on a shell script posted to RGRN by "Faux_Pseudo" # Written 12 Nov 2008 by John T. Wodder II # Last edited 14 Nov 2008 by John Wodder # Usage: deaths.pl [-sw] [logfile ...] # Options: # -s - If no logfiles are given on the command line, read from stdin instead # of /usr/games/lib/nethackdir/logfile # -w - Strip off any "while helpless" messages & similar stuff that comes # after a comma in the cause of death use strict; use Getopt::Std; our(%deaths, %opts); BEGIN { getopts('sw', \%opts); @ARGV or $opts{s} or @ARGV = ('/usr/games/lib/nethackdir/logfile'); } s/^[^,]*,//; $opts{w} && s/,.*$//; $deaths{$_}++; END { printf "%8d %s\n", $deaths{$_}, $_ for sort { $deaths{$b} <=> $deaths{$a} || $a cmp $b } keys %deaths }