if (defined($cgi->param('parse'))) { @lines = split(/\n/, $cgi->param('pasted')); my $line; $text .= "\n"; $text .= "\n"; $text .= "\n"; my $i = 0; my $cnt = 0; foreach $line (reverse @lines) { #3 + PG Power kaffee 178392 #4 – sand kaffee 176800 #5 * Done it Duncan XCT 159366 next unless ($line =~ /[^\s]/); my @valuez = split(/\t/, $line); next unless(defined($valuez[4])); foreach (@valuez) { s/^\s*//; s/\s*$//; } $valuez[0] =~ /^(\d+)/; $valuez[0] = $1; $valuez[4] =~ s/[^\d]//g; next unless (defined(($valuez[0]))); next if ($valuez[4] eq ""); next if ($valuez[4] =~ /[^\d]/); if ($i == 0) { $sth = $dbh->prepare("select platz from $uni{'name'}_ogame_players order by platz desc limit 1;"); $sth->execute(); my $last = $sth->fetchrow_array; for ($i = $last + 1; $i <= $valuez[0]; $i++) { $sth = $dbh->do("insert into $uni{'name'}_ogame_players set platz='$i';"); $cnt++; } $i = 1; } if (($valuez[0] =~ /(\d+)/) && ($valuez[1] ne "")){ $sth = $dbh->do("update $uni{'name'}_ogame_players set ally='$valuez[3]', punkte='$valuez[4]', name='$valuez[1]', date=NOW() where platz='$1';"); $cnt++; $text .= "\n"; } else { $text .= "\n"; } } $text .= "
Update (wenn leer, ging was schief!)
PlatzSpielerAllyPunkte
$1$valuez[1]"; if ($valuez[3] ne "") { $text .= $valuez[3]; } else { $text .= " "; } $text .= "$valuez[4]
\n$cnt Zeilen wurden verwendet"; }