The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

version 0.03

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

    zKH5bO
    eqSbWf
    ymaay0
    8rqWn0

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], and [0-9]) for a total of 62 characters, which may be mapped in 62 ^ 6.

EXPORT

The module exports the subroutine 'shorten_url' on request.

SUBROUTINES/METHODS

shorten_url( $url )

This function takes as arguments an URL to shorten, and the desired lenght of the shortened values, and returns an array reference containing 4 values.

The generated codes will be of six characters long.

ACKNOWLEDGMENT

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 at cpan.org>

BUGS

Please report any bugs or feature requests to bug-algorithm-url-shorten at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-URL-Shorten. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Algorithm::URL::Shorten

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2010 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.