Posts Tagged language perl

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:

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("" . $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;

, , ,

Leave a comment