Tatsuhiko Miyagawa has published WWW::Shorten::RevCanonical, rev=canonical URL shortening as a Perl module. Neat!

use WWW::Shorten 'RevCanonical';

my $short_url = makeashorterlink($long_url); # Note that this could fail and return undef

# Or, use WWW::Shorten::Simple wrapper
use WWW::Shorten::Simple;

my @shorteners = (
WWW::Shorten::Simple->new('RevCanonical'), # Try this first
WWW::Shorten::Simple->new('TinyURL'), # Then fallback to TinyURL

my $short_url;
for my $shortener (@shorteners) {
$short_url = $shortener->shorten($long_url)
and last;

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s