]> git.rmz.io Git - dotfiles.git/blob - bin/old/cr2html
fixes permissions on Skaro
[dotfiles.git] / bin / old / cr2html
1 #! /usr/bin/perl
2 # Does something to Ogame combat reports... Don't really care anymore
3
4 use strict;
5
6 my $input;
7
8 open (CREPORT, $input = "index.php.html") ||
9 die ("Could not open file: $!");
10 # print ("File opened\n");
11
12 open (CROUT, ">tmp");
13
14 #local $/;
15
16 my $atacker;
17 my $defender;
18
19 my $day;
20 my $month;
21
22
23 while (<CREPORT>) {
24 # Getting atacker and defender names
25 if (/>(.*)\ vs.\ (.*)</o){
26 $atacker = $1;
27 $defender = $2;
28 }
29
30 # getting the date
31 if (/(\d{2})\.(\d{2})\.\d{4}/o) {
32 $day = $1;
33 $month = $2;
34 }
35
36 # removing coords
37 # s/\[(\d+):(\d+):(\d+)\]/x:xxx:xx/g;
38 s/<a.*\/a>/<a>[x:xxx:xx]<\/a>/;
39
40 if (/<tr>[ \t\n]*<td>Weapons.*Armour.*<\/tr>/m) {
41 print STDERR ("yep\n");
42 }
43
44 print CROUT;
45 }
46
47 close(CREPORT); close(CROUT);
48
49 my $output = "$month.$day $atacker -vs- $defender.html";
50
51 rename ("tmp", "$output") ||
52 die ("Could not create file $output");
53 unlink ($input);
54
55 print ("$input renamed as $output\n");