#!/usr/local/bin/perl -w # checks whether the encyc script is reading all the files that are there. # # usage check_encyc.p < ~/bin/encyc sub bynumber { $a <=> $b; } $verbose = 0 ; $finish_ra = "finish_ra" ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $matches = 0 ; $mismatches = 0 ; $c = 0 ; while(<>){ if ( /cd (.*)$/ ) { $command = "cd $1 ; ls -1 |" ; open( I , $command ) ; @ls = ; } if (/$finish_ra \"([^"]+)\"\s+\"([^"]+)\"(.*)/ ) { $c++ ; $codes[$c] = $1 ; $xs[$c] = $2 ; $rest[$c] = $3 ; } } #$code = "816.1A3" ; #foreach $l (@ls) { # if ( $l =~ /$code.*1\.14/ ) { # print $l ; # } #} $C = $c ; foreach $c ( 1..$C ) { print "Checking:\n" , $codes[$c], "\n " , $xs[$c] , "\n" ; @codelist = split( ' ' , $codes[$c] ) ; $count = 0 ; reset 'a-b' ; foreach $code ( @codelist ) { print "Checking: " , $code, "\n" if ( $verbose ) ; foreach $l (@ls) { # if ( $l =~ /$code.*1\.14/ ) { # $debug = 1 ; # print "1!! " , $l , $a{1.14} if ($debug) ; # } else { $debug = 0 ; } if ( $l =~ /$code\..*\.(.\.[^.]+)[\s\n]+$/ ) { print $1," $count\n" if ($verbose) ; if ( !($a{$1}) ) { $b[$count] = $1 ; $a{$1} = 1 ; $count ++ ; } # print "3!! " , $l , $a{1.14} if ($debug) ; } # print "---!! " , $l , $a{1.14} if ($debug) ; } } @d = sort bynumber ( @b ) ; if ( $verbose ) { print " " , $xs[$c] , "\n" ; } if ( $verbose ) { print "these $count should match:\n" ; } $j = join ( ' ' , @d ) ; print " " , $j , "\n" ; if ( $j eq $xs[$c] ) { print "they do match!\n" ; $matches ++ ; } else { print "$finish_ra \"$codes[$c]\" \"$j\" $rest[$c]\n" ; $mismatches ++ ; } } print "$matches matches, $mismatches mismatch\n" ; # print @ls ;