#!/usr/bin/perl -w # Get a word from Merriam-Webster's online dictionary and print the definition. sub usage { print < -- returns the definition of the word. endofusage exit 1; } usage unless @ARGV == 1; my $host = "www.m-w.com"; my $port = 80; my $script = "/cgi-bin/netdict"; # Note that these headers do not contain the full query Netscape would post. # Those headers are here: #POST /cgi-bin/netdict HTTP/1.0 #Referer: http://www.m-w.com/netdict.html #Connection: Keep-Alive #User-Agent: Mozilla/3.0 (X11; I; Linux 2.0.30 i486) #Host: localhost:1600 #Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* #Content-type: application/x-www-form-urlencoded #Content-length: 32 # #book=Dictionary&va=canonicalword #12345678911234567892123456789312 #32 characters. This needs to be calculated separately and put in the #Content-length header for each word. my $headers = <