validateAll.pl

  1. $ERROR_FILE = 'c:\q\errors.log';
  2. $ALL_ERROR_FILE = 'c:\q\allerrors.log';
  3. $VALIDATOR = "c:\\q\\sp1_3\\bin\\nsgmls.exe -wxml -s -f $ERROR_FILE ";
  4. use Cwd;
  5. use File::Path;
  6. use File::Basename;
  7. sub directory
  8. {
  9. my (@list, $item);
  10. opendir DIR,".";
  11. @list = readdir DIR;
  12. #remove . and ..
  13. shift(@list);
  14. shift(@list);
  15. foreach $item (@list)
  16. {
  17. if (-f $item) {file($item);}
  18. if (-d $item) {
  19. chdir($item);
  20. directory($item);
  21. chdir ("..");
  22. }
  23. }
  24. }
  25. sub file
  26. {
  27. print "#";
  28. if($_[0]=~/\.xml/) {
  29. if(-e "$ERROR_FILE") {system "del $ERROR_FILE";}
  30. system ("$VALIDATOR $_[0]");
  31. if (open IN, "$ERROR_FILE")
  32. {
  33. read IN, $tmp, 1000000;
  34. close IN;
  35. chomp($tmp);
  36. if ($tmp ne '')
  37. {
  38. print OUT "\n\n:::Directory: ";
  39. print OUT cwd();
  40. print OUT " File: $_[0]\n";
  41. $tmp=~ s/c\:\\q\\sp1_3\\bin\\nsgmls\.exe\://g;
  42. print OUT $tmp;
  43. }
  44. }
  45. }
  46. }
  47. if(-e "$ALL_ERROR_FILE") {system "del $ALL_ERROR_FILE";}
  48. open OUT, ">>$ALL_ERROR_FILE";
  49. directory();
  50. close OUT;
  51. system ("notepad $ALL_ERROR_FILE");