#!/usr/bin/perl -w
use HTML::TreeBuilder;
use HTML::FormatText;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->agent("Dictionary");
#
# Uncomment if behind a firewall
#
#$ua->proxy([ 'http' ], 'http://www-dms.esd.sgi.com:8080/');
#
# Create a new request.
#
my $req = new HTTP::Request GET => "http://work.ucsd.edu:5141/cgi-bin/
+http_webster?isindex=$ARGV[0]&method=exact";
#
# Pass Request to the user agent and get a response back.
#
my $res = $ua->request($req);
#
# Print outcome of the response.
#
if(! $res->is_success) {
print "Failure to connect to server: " . $res->message;
} else {
my $html = $res->content;
my $p = HTML::TreeBuilder->new;
$p->parse($html);
my $formatter = HTML::FormatText->new(leftmargin => 0, rightmargin =
+> 60);
my $result = $formatter->format($p);
my @paragraphs = split /^\s+/m, $result;
#
# Print only the paragraphs where the word definition is
#
for(my $x=2; !($paragraphs[$x] =~ /^From WordNet/) and $x < 10; $x++
+) {
print $paragraphs[$x]."\n";
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|