String...mutake(3pm)

πŸ“¦
version 0.30 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– String::Koremutake β€” NAME πŸŽ€

String::Koremutake β€” the module that converts to and from Koremutake Memorable Random Strings. Cute name, does exactly what it says, no notes. πŸ’…

She's also the page living at String...mutake(3pm), iykyk ✨


🌸 SYNOPSIS 🌸

use String::Koremutake;
my $k = String::Koremutake->new;

my $s = $k->integer_to_koremutake(65535);        # botretre
my $i = $k->koremutake_to_integer('koremutake'); # 10610353957

That's the entire vibe bestie β€” make a string, read a string back. πŸ¦‹


✨ DESCRIPTION ✨

Okay so String::Koremutake converts to and from Koremutake Memorable Random Strings. Round trip, both directions, no drama. πŸ’œ

So the term "Memorable Random String"? That was coined by Sean B. Palmer as a name for those little strings like dopynl, glargen, glonknic, spoopwiddle, and kebble etc. β€” you know the ones. They mean literally nothing conventionally, but they slap as random identifiers, especially in URIs where you want them to stay persistent and not get lost. The receipts live at http://infomesh.net/2001/07/MeRS/.

Koremutake is a MeRS algorithm that Shorl uses (http://shorl.com/koremutake.php). And in their own words, fr: "It is, in plain language, a way to express any large number as a sequence of syllables. The general idea is that word-sounding pieces of information are a lot easier to remember than a sequence of digits."

Like… the way that brains remember syllables better than digit soup? That's the whole thesis and it's honestly iconic. πŸ§ πŸ’–


πŸ‘‘ INTERFACE πŸ‘‘

πŸŽ€ new()

The new() method is the constructor. You call it, you get an object, you move on with your life. πŸ’…

πŸ¦‹ integer_to_koremutake($i)

The integer_to_koremutake method converts a positive integer to a Koremutake string:

my $s = $k->integer_to_koremutake(65535);        # botretre

Number in, adorable little syllable string out. Obsessed. ✨

πŸ“ koremutake_to_integer($s)

The koremutake_to_integer method converts a Koremutake string to the integer it represents:

my $i = $k->koremutake_to_integer('koremutake'); # 10610353957

String in, number out. Round trip complete, no cap. πŸ”₯


⚠️ CAVEATS ⚠️

Listen up bestie, this one matters. You need to use bigint; if you want String::Koremutake to work with integers larger than what fits into a normal Perl integer β€” because otherwise they get converted to a floating point number on your platform before anything happens. πŸ’€

😭 Example

Without use bigint; big integers get converted to fixed precision floating point numbers:

$ perl -MString::Koremutake -le '
  my $a = 65536**4;
  my $k = String::Koremutake->new;
  foreach my $b ($a, $a+1, $a+2, $a+3) {
    print "$b: ".$k->integer_to_koremutake($b);
  }'
1.84467440737096e+19: bibababababababababa
1.84467440737096e+19: bibababababababababa
1.84467440737096e+19: bibababababababababa
1.84467440737096e+19: bibababababababababa

Look at that. Four different numbers. Same answer four times. It's giving precision loss. It's giving tragedy. 🫠

If you use that large integers, you should add use bigint; to your program which solves that issue:

$ perl -Mbigint -MString::Koremutake -le '
  my $a = 65536**4;
  my $k = String::Koremutake->new;
  foreach my $b ($a, $a+1, $a+2, $a+3) {
    print "$b: ".$k->integer_to_koremutake($b);
  }'
18446744073709551616: bibababababababababa
18446744073709551617: bibababababababababe
18446744073709551618: bibababababababababi
18446744073709551619: bibababababababababo

SLAY. Four numbers, four distinct strings, and the universe is healed. ✨ It will likely save you from other issues with big integers, too.

🚨 Note that foreach my $b ($a .. $a+3) doesn't work either, as the .. operator can't be overloaded. See CAVEATS in "perldoc bigint" for details. Not me warning you twice. πŸ™ˆ

πŸ’€ BUGS AND LIMITATIONS πŸ’€

No bugs have been reported. (A clean sheet. A spotless record. We love to see it. πŸ‘‘)

Please report any bugs or feature requests to bug-String-Koremutake@rt.cpan.org, or through the web interface at http://rt.cpan.org.


🌈 AUTHOR 🌈

Leon Brocard acme@astray.com β€” legend behavior, honestly. 🫢


Copyright (c) 2005, Leon Brocard acme@astray.com. All rights reserved.

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


That's the whole page bestie β€” every option, every caveat, every code block, untouched and unbothered. This documentation shipped with perl v5.36.0 and is dated 2022-10-13, and it lives under the manual name String...mutake(3pm). Go forth and make memorable random strings. πŸ’…βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from