Posted to tcl by yeeling at Mon Jul 02 10:16:42 GMT 2007view pretty

# ---
# the part for the first print that didn't work
# ---
$|=1;
my $nof=scalar @valfiles;
foreach (@valfiles)
{
    if ($nof==0)
    {
        warn "$datahome: Empty directory\n";
        $invfiles=1;
        return;
    }
    my $pct=sprintf("%.2f",($fc/$nof)*100);
    print STDOUT "\r$pct\% diaries read and checked ($fc of $nof files)...$_          ";
    ($ddref,$max_ln, $newidr,$delref,$oddqr)=rfile($_,$choice,$oracle,$cc);
    foreach (keys %$ddref)
    {
        if (exists $seen{$_})
        {
            print LOGFH "WARNING!!! duplicate key: $_???\n";
            warn "detected duplicate key: $_\n";
        }
        $ddats{$_}=$$ddref{$_} unless $seen{$_}++;
    }
}


# ---
# the part for the second print that worked
# ---
if (not exists $linelist{$_})
{
    my $stm=qq{insert into $oracle ($cols) values ($vals)};
    eval
    {
       my $sth=$dbh->prepare( $stm );
       $sth->execute();
    };
            
    if($@) 
    {
        warn "\r\tDatabase error $_: $DBI::errstr\r";
        print LOGFH "\n\tDatabase error $_: $DBI::errstr\n";
    }
    else
    {
        my $compp=sprintf("%.2f",($mark/$numk)*100);
        print STDOUT "\r\t$compp\% dids inserted       ";
    }
}