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

  1.  
  2. # ---
  3. # the part for the first print that didn't work
  4. # ---
  5. $|=1;
  6. my $nof=scalar @valfiles;
  7. foreach (@valfiles)
  8. {
  9. if ($nof==0)
  10. {
  11. warn "$datahome: Empty directory\n";
  12. $invfiles=1;
  13. return;
  14. }
  15. my $pct=sprintf("%.2f",($fc/$nof)*100);
  16. print STDOUT "\r$pct\% diaries read and checked ($fc of $nof files)...$_ ";
  17. ($ddref,$max_ln, $newidr,$delref,$oddqr)=rfile($_,$choice,$oracle,$cc);
  18. foreach (keys %$ddref)
  19. {
  20. if (exists $seen{$_})
  21. {
  22. print LOGFH "WARNING!!! duplicate key: $_???\n";
  23. warn "detected duplicate key: $_\n";
  24. }
  25. $ddats{$_}=$$ddref{$_} unless $seen{$_}++;
  26. }
  27. }
  28.  
  29.  
  30. # ---
  31. # the part for the second print that worked
  32. # ---
  33. if (not exists $linelist{$_})
  34. {
  35. my $stm=qq{insert into $oracle ($cols) values ($vals)};
  36. eval
  37. {
  38. my $sth=$dbh->prepare( $stm );
  39. $sth->execute();
  40. };
  41.  
  42. if($@)
  43. {
  44. warn "\r\tDatabase error $_: $DBI::errstr\r";
  45. print LOGFH "\n\tDatabase error $_: $DBI::errstr\n";
  46. }
  47. else
  48. {
  49. my $compp=sprintf("%.2f",($mark/$numk)*100);
  50. print STDOUT "\r\t$compp\% dids inserted ";
  51. }
  52. }