#! /usr/bin/perl -w use Socket; use strict; my $word = $ARGV[0] or die "Usage: mw word\n"; my $host = "www.m-w.com"; my $port = 80; my $socketaddr; my $content = "jump=$word"; # This seems to work with white space in word my $wholePage = ""; my $form = ""; my $buf = ""; my @listvalue = (); my @option = (); my $selections = 0; my $finished_selections = 0; my $reentry = 0; my $count = 0; while ($content) { openSock(); post ($content); $wholePage = ""; while ( ) { $wholePage .= $_; } close SOCK; print "****************************************"; # pick out the form, /s matches newline with '.' /g is greedy # /m matches internal newline if ( $wholePage =~ /The word you've entered isn't in the dictionary.*(
.*<\/PRE>)/gs ) {
	print "\nCan't find $word, but here are some suggestions\n";
	$form = $1;
}
elsif ($wholePage =~ /(
)/gs ) { $form = $1; $form =~ s/Get the.*Top 10 Most Popular Sites for.*//s; } else { die "Don't know what to do with $word\n"; } # this is heavy duty kludge, geared toward www.m-w.com, needs maintenance # find out if the form has a selection of options $selections = 0; if ($form =~ /