Handbook Acronyms
Warren Block
wblock at wonkity.com
Wed Jul 14 02:53:49 UTC 2004
On Wed, 14 Jul 2004, Ceri Davies wrote:
[glossary]
> Great - it's at
> doc/en<mumble>/share/sgml/glossary/freebsd-glossary.sgml.
Okay, as a first step at defining all these terms, here's a little Perl
snippet (requires 5.8, I think) that creates a list of acronyms used in
the Handbook and removes those terms already present in the glossary.
Surprisingly, it turns out that the terms presently defined in the
glossary are not used in the Handbook at all, and vice versa.
(I can't escape the feeling that this could be done in about two lines
of Perl if I had a better handle on it. 8-)
-Warren Block * Rapid City, South Dakota USA
-------------- next part --------------
#!/usr/bin/perl
# List acronyms used in the FreeBSD Handbook but not yet
# defined in the Glossary.
# WB, 20040713
use strict;
use warnings;
use File::Find;
use Switch;
my $dir = '/usr/doc/en_US.ISO8859-1/books/handbook/';
my $glossary = '/usr/doc/en_US.ISO8859-1/share/sgml/glossary/freebsd-glossary.sgml';
my $fileext = '.sgml';
my %acronyms;
# add terms to list
find(\&wanted, $dir);
# remove terms already defined in glossary
terms($glossary,'del');
my @sorted = sort keys %acronyms;
foreach (@sorted) {
print "$_\n";
}
exit 0;
sub wanted {
my($fname) = $_;
if ((-f $fname) and ($fname =~ /$fileext/)) {
terms($fname, 'add');
}
}
sub terms {
my($fname, $op) = @_;
open my $fh, $fname or die "** couldn't open '$fname'--$!";
while (<$fh>) {
if (/<acronym>(\w+)/) {
switch ($op) {
case 'add' { $acronyms{uc($1)} = 1 }
case 'del' { delete $acronyms{uc($1)} }
}
}
}
close $fh or die "** couldn't close '$fname'--$!";
}
More information about the freebsd-doc
mailing list