+
+ my $cdrid = ($1-1900). $2; #2009 -> 109 so we fit in a bigint
+
+ unless ( $cdrs ) { #inefficient
+ my $dsth = dbh->prepare(
+ 'SELECT cdrid FROM cdr WHERE cdrid IS NOT NULL AND cdrid = ?'
+ ) or die dbh->errstr;
+ $dsth->execute($cdrid) or die $dsth->errstr;
+ my $row = $dsth->fetchrow_arrayref;
+ if ( $row && $row->[0] eq $cdrid ) { # == w/ 8 byte int?
+ warn "$cdrid (dup)\n" if $DEBUG > 1;
+ next;
+ }
+ }
+ warn "$cdrid\n" if $DEBUG > 1;
+
+ $content =~ s/(.*?)<\/form>//is;
+ my $cdr_content = $1;
+
+ my %cdr = ();
+ while ( $cdr_content =~
+ s/.*?<input name="(\w+)" type="\w+" value="([^"]+)" \/>//is )
+ {
+ warn " $1 => $2\n" if $DEBUG > 2;
+ $cdr{$1} = $2;
+ }
+
+ $cdrs++;