Annotation of doc/help/usage.pl, revision 1.1
1.1 ! albertel 1: #!/usr/bin/perl
! 2: use strict;
! 3:
! 4: use HTML::TokeParser;
! 5: use Getopt::Long;
! 6:
! 7: my ($help) = (0,0,0);
! 8: &GetOptions( "help" => \$help);
! 9:
! 10: sub get_all_files {
! 11: my $dir="../../loncom/html/adm/help/tex/";
! 12: opendir(DIR,$dir);
! 13: my @files=sort {uc($a) cmp uc($b)} (readdir(DIR));
! 14: return @files;
! 15: }
! 16:
! 17: sub get_usage {
! 18: my ($which)=@_;
! 19: my @files;
! 20: my $p = HTML::TokeParser->new("$which.manual.texxml");
! 21: while (my $token = $p->get_token()) {
! 22: if ($token->[0] eq 'S' && $token->[1] eq 'file') {
! 23: push(@files,$token->[2]{'name'});
! 24: }
! 25: }
! 26: return @files;
! 27: }
! 28:
! 29: sub print_unused {
! 30: my ($all,$usage)=@_;
! 31: my %all;
! 32: my %no_exist;
! 33: foreach my $file (@{ $all }) {$all{$file}=0;}
! 34: foreach my $list (@{ $usage }) {
! 35: foreach my $file (@{ $list }) {
! 36: if (exists($all{$file})) { $all{$file}++; } else { $no_exist{$file}++; }
! 37: }
! 38: }
! 39: print("Usage count for existing Files:\n");
! 40: foreach my $file (sort {uc($a) cmp uc($b)} (keys(%all))) {
! 41: printf("%-50s: %s\n",$file,$all{$file});
! 42: }
! 43: print("Usage count for nonexistint Files:\n");
! 44: foreach my $file (sort {uc($a) cmp uc($b)} (keys(%no_exist))) {
! 45: printf("%-50s: %s\n",$file,$no_exist{$file});
! 46: }
! 47: }
! 48:
! 49: sub main {
! 50: my @all_files=&get_all_files();
! 51: my @author_usage=&get_usage('author');
! 52: my @course_usage=&get_usage('course');
! 53: my @developer_usage=&get_usage('developer');
! 54:
! 55: &print_unused(\@all_files,[\@author_usage,\@course_usage,
! 56: \@developer_usage]);
! 57: }
! 58:
! 59: &main;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>