-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtop.pl
More file actions
executable file
·78 lines (65 loc) · 1.42 KB
/
top.pl
File metadata and controls
executable file
·78 lines (65 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/local/bin/perl -w
use strict;
# $Id: top.pl,v 1.1 2003/12/04 01:34:32 jepace Exp $
my @classes = (
"Archeologist",
"Barbarian",
"Caveman",
"Healer",
"Knight",
"Monk",
"Priest",
"Rogue",
"Ranger",
"Samurai",
"Tourist",
"Valkyrie",
"Wizard",
);
my $cmd;
my ($rank, $points, $user);
my $message;
my %table;
my $debug = 0;
my $me = shift;
foreach my $class ( sort @classes )
{
print "Class: $class\n" if $debug;
my $found = 0;
$cmd="/usr/local/bin/nethack -s -v -p $class";
open FILE, "$cmd |" or die "$cmd: $!\n";
while ( <FILE> )
{
next if /^\s*$/;
next if /^\s*No\s*Points/;
next unless /^\s*\d+/; # kill 3rd tombstone line
$message = $_;
($rank, $points, $user) = /^\s*(\d+)\s+(\d+)\s+(\w+)-/;
$message .= <FILE>;
if ($debug)
{
print "User: $user, Rank: $rank, Points: $points\n";
print "Message: $message\n\n";
}
if (defined $me)
{
if ( $user eq $me )
{
$found++;
$table{$rank} = $message;
last;
}
}
else
{
$table{$rank} = $message;
last;
}
}
close FILE;
print "Never played $class\n" if (defined $me && ! $found);
}
foreach ( sort {return $a <=> $b; } keys %table )
{
print $table{$_};
}