summaryrefslogtreecommitdiff
path: root/src/layout_parse.pl
blob: f0d055afa4e5b562df9df15ea69d0723c816628a (plain)
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
#!/usr/bin/perl

opendir(DIR, ".") || die;
@files = readdir(DIR);
closedir(DIR);

$max = 0;
$maxpos = -1;
$sum = 0;
$min = 99999999;
$minpos = -1;
$count = 0;

for $file(@files)
{
    if ($file =~ /(\d+)typhoon\.log/)
    {
        $num = $1;
        open(FILE, $file);
        while(<FILE>)
        {
            if (/\((\d+) nps\)\./)
            {
                $count++;
                $speed = $1;
                $sum += $speed;
                if ($speed > $max)
                {
                    $maxpos = $num;
                    $max = $speed;
                }
                if ($speed < $min)
                {
                    $minpos = $num;
                    $min = $speed;
                }
            }
        }
        close(FILE);
    }
}

printf "max $max at $maxpos, min $min at $minpos, avg %f\n", ($sum/$count);