Alessandro Ghedini

NAME

Algorithm::URL::Shorten - URL shortening algorithm.

VERSION

version 0.07

SYNOPSIS

Algorithm::URL::Shorten generates short codes used to map and represent longer URLs.

    use Algorithm::URL::Shorten qw(shorten_url);

    my $shorts = shorten_url("http://perl.org");

    foreach $code (@{$shorts}) {
        print $code, "\n";
    }

This code prints

    iqGzim
    S515va
    qmKrq8
    HXv4HD

DESCRIPTION

The codes generated with Algorithm::URL::Shorten are unique for every URL, so that every time it is used on the same URL, it will generate the same codes.

The short strings are alphanumeric ASCII ([a-z,A-Z,0-9]) for a total of 62 characters, which may be mapped in 62 ^ 6 different codes.

EXPORT

The module exports the subroutine shorten_url on request.

SUBROUTINES

shorten_url( $url )

This function takes as arguments an URL to shorten, and returns an array reference containing 4 strings.

The generated codes will be of six characters long.

ACKNOWLEDGMENTS

From version 0.03 the algorithm for generating short codes has slightly changed due to some bugs in the code. The codes generated by the algorithm v0.02 and v0.01 are not compatible with the new version.

AUTHOR

Alessandro Ghedini <alexbio@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2011 Alessandro Ghedini.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.