]> git.rmz.io Git - dotfiles.git/blobdiff - bin/old/cr2html
merge bin from shada
[dotfiles.git] / bin / old / cr2html
diff --git a/bin/old/cr2html b/bin/old/cr2html
new file mode 100755 (executable)
index 0000000..58f584a
--- /dev/null
@@ -0,0 +1,55 @@
+#! /usr/bin/perl
+# Does something to Ogame combat reports... Don't really care anymore
+
+use strict;
+
+my $input;
+
+open (CREPORT, $input = "index.php.html") || 
+       die ("Could not open file: $!");
+# print ("File opened\n");
+
+open (CROUT, ">tmp");
+
+#local $/;
+
+my $atacker;
+my $defender;
+
+my $day;
+my $month;
+
+
+while (<CREPORT>) {
+#      Getting atacker and defender names
+       if (/>(.*)\ vs.\ (.*)</o){
+               $atacker = $1;
+               $defender = $2;
+       }
+       
+#      getting the date
+       if (/(\d{2})\.(\d{2})\.\d{4}/o) {
+               $day = $1;
+               $month = $2;
+       }
+       
+#      removing coords
+#      s/\[(\d+):(\d+):(\d+)\]/x:xxx:xx/g;
+       s/<a.*\/a>/<a>[x:xxx:xx]<\/a>/;
+       
+       if (/<tr>[ \t\n]*<td>Weapons.*Armour.*<\/tr>/m) {
+               print STDERR ("yep\n");
+       }
+       
+       print CROUT;
+}
+
+close(CREPORT); close(CROUT);
+
+my $output = "$month.$day $atacker -vs- $defender.html";
+
+rename ("tmp", "$output") ||
+       die ("Could not create file $output");
+unlink ($input);
+
+print ("$input renamed as $output\n");