Number...Locator(3pm)
π Number::RecordLocator β the perl manual page, but make it cute π
okay bestie, so this is the Number...Locator(3pm) page from your User Contributed Perl Documentation, and it's genuinely one of the slayest little modules out there. no cap.
β¨ NAME β¨
Number::RecordLocator β it encodes integers into a short and easy to read and pronounce "locator string". it's giving airport booking code but make it Perl π«
β¨ SYNOPSIS β¨
okay so here's the whole vibe, look:
use Number::RecordLocator;
my $generator = Number::RecordLocator->new();
my $string = $generator->encode("123456");
# $string = "5RL2";
my $number = $generator->decode($string);
# $number = "123456";
like. 123456 goes in, "5RL2" comes out, and it comes right back. periodt. π
β¨ DESCRIPTION β¨
Number::RecordLocator takes integers and encodes them into a 32 character "alphabet" that was designed to be short and easy to read and pronounce. because honestly? reading out O0Il1 over the phone is a crime and we're not doing it anymore.
the encoding maps, exactly like this:
0 to O
1 to I
S to F
B to P
so with a 32 bit encoding, you can map 33.5 million unique ids into a 5 character code. five characters!! iconic. π
real talk tho β this certainly isn't an exact science and the author isn't yet 100% sure of the encoding. feedback is much appreciated. so if you have thoughts, send them, bestie π«Ά
πΈ new πΈ
Instantiate a new Number::RecordLocator object. right now, we don't actually store any object-specific data, but in the future, we might. so it's just out here, living its main character life, storing nothing π
πΈ init πΈ
Initializes our integer to character and character to integer mapping tables. it's the little setup gremlin behind the scenes π§
πΈ encode INTEGER πΈ
Takes an integer. Returns a Record Locator string. that's it, that's the whole thing β¨
πΈ decode STRING πΈ
Takes a record locator string and returns an integer. heads up though: if you pass in a string containing an invalid character, it returns undef. so vibe check your input first π
πΈ canonicalize STRING πΈ
so to compare a Record Locator string with another one, you could do this:
print "ALWAYS TRUE\n" if $generator->decode("B0") == $generator->decode("PO");
and like, sure. valid. but this method provides an alternative:
my $rl_string = $generator->encode(725);
print "ALWAYS TRUE\n" if $generator->canonicalize("b0") eq $rl_string;
print "ALWAYS TRUE\n" if $generator->canonicalize("BO") eq $rl_string;
print "ALWAYS TRUE\n" if $generator->canonicalize("P0") eq $rl_string;
print "ALWAYS TRUE\n" if $generator->canonicalize("po") eq $rl_string;
look at that. b0, BO, P0, po β all of them normalize to the same thing and it's ALWAYS TRUE every single time. the way that *works*β¦ obsessed. π₯
This is primarily useful if you store the record locator rather than just the original integer and don't want to have to decode your strings to do comparisons. so you skip the whole decode-everything-every-time situation. efficiency queen π
Takes a general Record Locator string and returns one with character mappings listed in "DESCRIPTION" applied to it. This allows string comparisons to work. This returns undef if a non-alphanumeric character is found in the string. so no weird symbols sneaking in, okay? π«
β¨ BUGS AND LIMITATIONS β¨
No bugs have been reported. (slay, honestly, we love a clean bug tracker πβ¨)
Please report any bugs or feature requests to bug-number-recordlocator@rt.cpan.org, or through the web interface at http://rt.cpan.org.
β¨ AUTHOR β¨
Jesse Vincent <jesse@bestpractical.com> β thank you king π
β¨ LICENCE AND COPYRIGHT β¨
Copyright (c) 2006, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
aaaand that's the whole page bestie π¦ it's perl v5.36.0, dated 2022-12-12, and this was the Number...Locator(3pm) page β go forth and encode responsibly, ily πππΈ
π¦ where this page comes from
- debian bookworm: libnumber-recordlocator-perl 0.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnumber-recordlocator-perl 0.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnumber-recordlocator-perl 0.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnumber-recordlocator-perl 0.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnumber-recordlocator-perl 0.005-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms