NAME

Data::ID::URL::Shrink - Shorten numeric IDs, for nicer URLs and more.

SYNOPSIS

use Data::ID::URL::Shrink qw(:all);
-- or --
use Data::ID::URL::Shrink qw(:encoding);

my $id = shrink_id(123456789);    # shorten your numeric ID.
my $numeric_id = stretch_id($id); # get your numeric ID back.

DESCRIPTION

Data::ID::URL::Shrink will shorten a numeric ID, and can randomly generate IDs for you, based on its own Base50 character set.

By default, a random_id() call will return an 11-character id. Optionally, you can generate IDs of specific character lengths, but no shorter than 3 characters.

This module DOES NOT GUARANTEE unique IDs. It supplements them.

FUNCTIONS

Export functions individually or use tags -- ':encoding' or ':all'.

shrink_id

my $id = shrink_id(123456789);

Give this function a numeric ID and get a shorter, encoded one in return.

stretch_id

my $numeric_id = stretch_id($id);

Get a numeric value back from a previously encoded id.

random_id

# NOTE: If argument is passed, must be n > 2.
my $id = random_id(); # Generate a random 11-character ID.
my $id = random_id(n); # Generate a random n-character ID.

Just remember: the lower the character length value, the smaller the set of possible unique IDs.

ACKNOWLEDGEMENTS

mst

Thanks for help with the module name and answering PAUSE and CPAN questions.

internets

Thanks to the authors of the articles, Q&A posts, etc. which I read to get this module working.

AVAILABILITY

GitHub https://github.com/yakubori/Data-ID-URL-Shrink

COPYRIGHT

Copyright (C) 2013 Rick Yakubowski (yakubori) <yakubori@cpan.org>

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Rick Yakubowski (yakubori) <yakubori@cpan.org>