#!/usr/local/bin/perl -w # # FILE: webster.pl # AUTHOR: Stephanie Schaaf (sas@cs.brown.edu) # Michael Radwin (mradwin@adobe.com) # DATE: Tue Mar 4 19:55:11 EST 1997 # MODIFIED: Wed Nov 5 15:07:56 PST 1997 # DESCR: simple webster hack # $TRAILER = 'Pronunciation Key'; $TRAILER2 = '____________________________________________________'; $TRAILER3 = 'Get the Word of the Day e-mailed every morning.'; $TRAILER4 = 'Click here'; $HEADER = 'Main Entry'; $NOTFOUND = 'No entries found that match your query.'; $lynx = '/usr/local/bin/lynx'; $flags = '-nolist -dump'; $url = 'http://www.m-w.com/cgi-bin/netdict?book=Dictionary&va='; if (($#ARGV == -1) || ($ARGV[0] eq "-h")) { print("Usage: webster word [words ...]\n"); exit(2); } die "webster: can't run $lynx\n" unless -x $lynx; @words = @ARGV; WORD: while ($word = shift(@words)) { open(LINES, "$lynx $flags '$url$word' |") || die "webster: can't run $lynx: $!\n"; while () { if (/$HEADER/o) { print; last; } if (/$NOTFOUND/o) { print("$word: not found\n\n"); next WORD; } } while () { last if /$TRAILER|$TRAILER2|$TRAILER3|$TRAILER4/o; next if /^\s*$/; print; } print "\n"; }