#!/usr/local/bin/perl # ------------------------------------------------------------ # anag.cgi # # anagrams. # # Maintenace Log # -------------- # mg: browse function; self-referencing script require '/opt/apache/share/cgi-bin/cgi-lib.cgi'; #require '/edgar/tools/Edgarlib/edgarlib'; #require '/edgar/tools/Edgarlib/look.pl'; # Required for binary search #require '/edgar/tools/Edgarlib/cgi-lib.pl'; &html_header("Anagrams"); # from cgi-lib.pl $Date = `date`; # Get the input # # If first time, RQST METHOD IS a get!! # Set it to A then, and set limit to 15. # &parse_request if defined $ENV{'REQUEST_METHOD'}; # print "env req is: $ENV{'REQUEST_METHOD'}" if defined $ENV{'REQUEST_METHOD'}; &init if $ENV{'REQUEST_METHOD'} eq "GET"; if ($ENV{'REQUEST_METHOD'} eq "POST") { $msg = 1; } # # If debugging on, show all the keys and values from the form. # #if ($query{'debug'} =~ /no debug/) { } #else{ # &show_debug_info; } $prog = "/opt/apache/share/cgi-bin/anagram"; # name of c-program $hitctr = 0; # hit counter variable # # Mod: use Dict flag = 0 - *all* characters # print<

Ye Olde Free Berkeley Anagram Generator

ENDOFTBLHDR $word = $query{'name'}; if ($msg) { # if not the first time, it's a POST, --- process. $word =~ tr/[A-Z]/[a-z]/; # change to lower case. print "We are processing the phrase: $word
"; $bla = `$prog < /usr/dict/words $word > /tmp/word.$$`; # form anags. $prt = `cat /tmp/word.$$`; # print it out to STDOUT $prt =~ s/\n/
/g; # put in BR tags # ($foo,$rest) = `wc -l /tmp/word.$$`; $foo = `cat /tmp/word.$$ | wc -l`; # $foo =~ s/(.*)\s.*$/$1/; # get rid of fluff # $foo =~ /.*\s.*/; # $first = $1; # @foo = split(/\s/,$foo); } # end the if / then test for first-time around. &print_html; if ($msg) { print "
"; print "$prt"; print "
"; print "You generated $foo anagrams from $word...

Go to Top"; } &trlr; exit 0; sub show_debug_info { while (($key,$value) = each(%query)) { print "The value of $key is $value
"; } } exit 0; # # set up the form, self-referencing. user enters new lastn ame. # sub print_html { print< Name or Phrase to Anagramize (don't worry about quote marks)

Submit choices: . Reset form: . ENDOFHTML } sub init { # print "First time around"; $msg = 0; $query{'name'} = " "; } sub trlr { print< 'author': Mark Ginsburg, created from freely available internet tools. Mail me with comments or suggestions. Amusing phrases to try: "Harvard Business School", "Surepay Earnings Statement", "Knowledge is Power." ENDOFT }