Drop invalid WRs rather than attempt to coerce them to ints
authorMartyn Smith <martyn@catalyst.net.nz>
Thu, 29 May 2008 01:45:12 +0000 (13:45 +1200)
committerMartyn Smith <martyn@catalyst.net.nz>
Thu, 29 May 2008 01:45:12 +0000 (13:45 +1200)
tks.pl

diff --git a/tks.pl b/tks.pl
index 8f1489d1f76fba7b8058e708cf048f8cd3e78a7e..b1169471a06226cd9a12003e6204b1bb783a9136 100755 (executable)
--- a/tks.pl
+++ b/tks.pl
@@ -37,9 +37,14 @@ my $total_time = 0;
 # if the wr is in the map, substitute
 foreach my $entry ( @data ) {
     $entry->{wr} = $wrmap->{$entry->{wr}} if exists $wrmap->{$entry->{wr}};
-    $entry->{wr} = int($entry->{wr});
+    unless ( $entry->{wr} =~ m{ \A \d+ \z }xms ) {
+        warn "Invalid WR '$entry->{wr}'\n";
+        # TODO: perhaps interactively add these?
+    }
 }
 
+@data = grep { $_->{wr} =~ m{ \A \d+ \z }xms } @data;
+
 # sort dataz by date, then WR
 @data = sort { $a->{date} cmp $b->{date} or $a->{wr} <=> $b->{wr} } @data;