Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A Perl^h^h^h^hRuby script to create Tiny URLs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A Perl^h^h^h^hRuby script to create Tiny URLs
Authored by: pkishor on Jul 05, '06 04:08:43PM
now, now... that is not nice... to disparage Perl and CPAN...

#!/usr/bin/perl

use LWP;
my $a = LWP::UserAgent->new;

my $q = HTTP::Request->new(POST => 'http://tinyurl.com/create.php');
$q->content_type('application/x-www-form-urlencoded');
$q->content("url=$ARGV[0]");

my $r = $a->request($q);

if ($r->is_success) {
  my $h = $r->decoded_content;
  $h =~ /<blockquote><b>http:\/\/tinyurl.com\/(.*?)<\/b>/;
  print "http://tinyurl.com/$1";
}

>perl tinyurl.pl http://www.macosxhints.com
http://tinyurl.com/4oh69
>


[ Reply to This | # ]