Data::ID::URL::Shrink - Shorten numeric IDs, for nicer URLs and more.
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.
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.
Export functions individually or use tags -- ':encoding' or ':all'.
my $id = shrink_id(123456789);
Give this function a numeric ID and get a shorter, encoded one in return.
my $numeric_id = stretch_id($id);
Get a numeric value back from a previously encoded 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.
Thanks for help with the module name and answering PAUSE and CPAN questions.
Thanks to the authors of the articles, Q&A posts, etc. which I read to get this module working.
GitHub https://github.com/yakubori/Data-ID-URL-Shrink
Copyright (C) 2013 Rick Yakubowski (yakubori) <yakubori@cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Rick Yakubowski (yakubori) <yakubori@cpan.org>
To install Data::ID::URL::Shrink, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::ID::URL::Shrink
CPAN shell
perl -MCPAN -e shell install Data::ID::URL::Shrink
For more information on module installation, please visit the detailed CPAN module installation guide.