I saw http://www.makeashorterlink.com/ and thought it was a pretty useful idea for posting/mailing really long links. I whipped up a small script to do the same thing sans advertising.

#!/usr/local/bin/perl -w =head1 uri.cgi Create short URL re-directs, similar to www.makeashorterlink.com =head1 Usage When passed a valid redirect uri it sends the user to the appropriate link. When passed an http uri it creates a new redirect uri or returns existing one. uri.cgi?1062698960 uri.cgi?http://www.sfu.ca/~ajdelore/ =cut use strict; use CGI qw (header redirect url); my $path_to_data = "./.uri_data"; my $uri = $ENV{QUERY_STRING} or &bad_query_string; if ($uri =~ qr(^\d+$) || $uri =~ qr(^http://)) { open (URI_DATA,"+>> $path_to_data"); my %uri_data; while (<URI_DATA>) { chomp; my ($key,$value) = split; $uri_data{$key} = $value; } if ($uri_data{$uri}) { print redirect($uri_data{$uri}); } elsif ($uri =~ qr(^http://)) { my %data_uri; foreach (keys %uri_data) { $data_uri{$uri_data{$_}} = $_; } my $key = ($data_uri{$uri} || time); print URI_DATA "$key $uri\n"; print header (-type=>'text/plain'); print "The link is ", url, "?$key" } else { &bad_query_string } close URI_DATA; } else { &bad_query_string } sub bad_query_string { print header (-type=>'text/plain'); print "Bad query string supplied.\n"; exit; }

I also created a javascript (ick, I know) bookmarklet to quickly create links. Granted, it doesn't actually work for me except on the 6-7 sites where I allow javascript, but nonetheless...

javascript:void(location='http://path/to/uri.cgi?'+location)

</ajdelore>


In reply to Shorter links for email/posts by ajdelore

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.