Quick ‘n dirty anagrammer using the Internet Anagram Server

I was bored one day and noticed that the an(6) program wasn’t in Red Hat’s repos. So I wrote a Perl script to talk to the Internet Anagram Server’s HTTP interface:

#!/usr/bin/perl
use strict;
use warnings;

use HTTP::Client;
use URI::Escape;

my $client   = HTTP::Client->new();
my $string   = uri_escape(join(" ", @ARGV));
my $document = $client->get("http://www.wordsmith.org/anagram/anagram.cgi?anagram=" . $string . "&t=1000&a=n");
my $start    = index($document, "Anagrams for: $string</h3>");
my $end      = index($document, '<bottomlinks>');
my $relevant = substr($document, $start, ($end - $start));
$relevant    =~ s/<.*>//g;
print $relevant;
Advertisements

, , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: