3 /***************************************************************************
4 * Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
26 use DBD::Pg qw(:pg_types);
33 for my $file ("/home/whale/db.pl")
35 unless (my $return = do $file){
36 warn "couldn't parse $file: $@" if $@;
37 warn "couldn't do $file: $!" unless defined $return;
38 warn "couldn't run $file" unless $return;
41 $dbh->do("SET CLIENT_ENCODING TO 'LATIN1';");
43 my $file = get("http://game.planetarion.com/manual.php?page=stats");
45 my $st = $dbh->prepare(q{INSERT INTO ship_stats (name,"class",target,"type",init,guns,armor,damage,eres,metal,crystal,eonium,race) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)});
46 while ($file =~ /((?:\w| )+)<\/td><td>(\w+)<\/td><td>(\w+)<\/td><td>(\w+)\D+(\d+)\D+(\d+)\D+(\d+)\D+?(\d+|-)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+\d+\D+\d+.+?(\w+)<\/td>/g){
48 $dmg = 0 if $dmg eq '-';
49 $st->execute($1,$2,$3,$4,$5,$6,$7,$dmg,$9,$10,$11,$12,$13) or die $dbh->errstr;
50 #print "$1,$2,$3,$4,$5,$6,$7,$dmg,$9,$10,$11,$12,$13\n";