home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
-
- $strategy = 'standout';
- $USAGE = "usage: $0 [-f localdict] files ...\n";
-
- if ($ARGV[0] eq '-f') {
- shift;
- $WORDS = shift || die $USAGE;
- &read_dict;
- } elsif (-r ($WORDS = $ENV{'HOME'} . '/.ispell_words')) {
- &read_dict;
- }
-
- sub read_dict {
- open WORDS || die "can't open $WORDS $!";
- while (<WORDS>) {
- chop; $seen{$_}++;
- }
- }
-
- die $USAGE unless @ARGV;
-
- $code = "while (<>) {\n study;\n";
- if ($strategy ne 'underline') {
- # ($SO, $SE) = ('*[ ', ' ]*'); # like diction
- ($SO, $SE) = ("\033[7m", "\033[m"); # vt100 standout
- }
- open(SPELL, "spell @ARGV |");
- while (<SPELL>) {
- chop;
- next if $seen{$_};
- ($lhs = $_) =~ s/(\W+)/\\$1/g;
- if ($strategy eq 'underline') {
- s/(.)/$1\b$1/g;
- $code .= " s/\\b$lhs\\b/$_/g;\n";
- } else {
- $code .= " s/\\b$lhs\\b/$SO$_$SE/g;\n";
- }
- }
- close(SPELL) || die "can't spell @ARGV";
- $code .= " print;\n}\n";
- #print STDERR $code;
- open (PAGER, "| ". ($PAGER = $ENV{'PAGER'} || 'more') . " -f");
- select(PAGER);
- eval $code;
- die $@ if $@;
- close(PAGER);
- die "$PAGER pipe failed" if $?;
-