Hi:

Thanks for the dictionary.com script. This is a very
nice way to demonstrate ruby. I have modified the
code for machines behind a proxy server if anyone
is interested.

require "net/http"

def usage
  STDERR.puts <<-USAGE
  Usage: #{File.basename $0} word
    Output is directed to STDOUT.
  USAGE
end#usage

if ARGV.size != 1
  usage
  exit 1
end

@url = "www.dictionary.com"
@proxy_addr = 'your.proxy.here'
@proxy_port = proxy_port_number


def lookup(word)
  Net::HTTP::Proxy(@proxy_addr, @proxy_port).start( @url ) { |http|
    a = http.get("/cgi-bin/dict.pl?term=#{word}")[1]

    if ( /No entry found for/  =~ a )
      puts "No entry found for '#{ARGV[0]}' - Suggestions:\n\n"

      while /<a href="\/cgi-bin\/dict.pl\?term=\w+">(\w+)/ =~ $'
        puts $1
      end
    else
      while a =~ /<!-- resultItemStart -->/
        /<!-- resultItemEnd -->/ =~ $'
        a = $'

        puts $`.gsub(/<.*?>/m) { |i|
        case i
          when "<b>"
            ""
          when "</b>"
            "\n"
          when "<p>"
            ""
          else
            ""
        end#case
        }
      end#while
    end#if
  }
end#lookup

lookup ARGV[0]



=========================================================
Jim Freeze
jim / freeze.org
---------------------------------------------------------
Today is a fine day for Ruby programming.
http://www.freeze.org
=========================================================