Permalink
Browse files

playing with URL shortener dumbness

  • Loading branch information...
yannk committed Apr 7, 2009
0 parents commit ff0a09b872ba8f57d7ad466ad1c77a8399dff0c3
Showing with 31 additions and 0 deletions.
  1. +31 −0 chain.pl
@@ -0,0 +1,31 @@
+#/usr/bin/perl
+use warnings;
+use strict;
+use CPANPLUS::Backend;
+use WWW::Shorten;
+
+my @urls = ();
+my $url = shift or die "usage: $0 <url>";
+
+my $cb = CPANPLUS::Backend->new();
+#warn Dump [$cb->search( type => 'module', allow => [ qr/^WWW::Shorten/ ])];
+for my $pkg (grep { /^WWW::Shorten::/ } map { $_->module } $cb->installed) {
+ no strict 'refs';
+ eval "use $pkg";
+ if ($@) {
+ next;
+ }
+ my $meth = *{ "$pkg\::makeashorterlink" };
+ my $new_url = eval {
+ $meth->($url);
+ };
+ if ($@) {
+ warn "Error making a short with $pkg: $@";
+ next;
+ }
+ next unless $new_url;
+ push @urls, $url;
+ $url = $new_url;
+}
+print join "\n", reverse @urls;
+print "\n";

0 comments on commit ff0a09b

Please sign in to comment.