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


Click here to return to the 'A Perl 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 script to create Tiny URLs
Authored by: juanfal on Jul 06, '06 09:23:54AM
Thanks a lot for these so many ideas...

I have improved a little bit the Perl code (that I consider more usable and flexible than specific AppleScripts or long specific curl command lines with many scaped chars!)

#!/usr/bin/env perl
#
# testtinyurl.pl
#
# juanfc 2006-06-30
#
# 
use strict;
use warnings;

# use WWW::Shorten 'BabyURL';
# use WWW::Shorten 'Linkz';
# use WWW::Shorten 'MakeAShorterLink';
# use WWW::Shorten 'Metamark';
# use WWW::Shorten 'NotLong';
# use WWW::Shorten 'OneShortLink';
# use WWW::Shorten 'Shorl';
# use WWW::Shorten 'SnipURL';
# use WWW::Shorten 'TinyClick';
# use WWW::Shorten 'TinyLink';
use WWW::Shorten 'TinyURL';

use Data::Validate::URI qw(is_uri);

if (!@ARGV) {
    my $a = `pbpaste`;
    if ( !is_uri($a) ) {
        $a = "http://$a";
    }    
    my $small = makeashorterlink($a);
    system("echo -n $small | pbcopy" );
    print "$smalln";
} else {
    foreach my $a (@ARGV) {
        if ( !is_uri($a) ) {
            $a = "http://$a";
        }
        print makeashorterlink("$a"), "n";
    }
}
If you want to use NotLong (very interesting), you can set the preferred nickname easily:
makeashorterlink($long_url,nickname=>$nickname);
but the philosophy of NotLong seems to be more to have a real nickname for a stable site.

It's pity WWW::Shorten doesn't have support for urlx.org.

[ Reply to This | # ]