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;
}