String::Dirify(3pm)

πŸ“¦
version 1.03 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– String::Dirify πŸ’–

okay bestie so this is String::Dirify β€” a User Contributed Perl Documentation page, and it's literally about turning a string into a directory name. that's the whole vibe. πŸŽ€


✨ NAME ✨

String::Dirify β€” Convert a string into a directory name 🌸


✨ Synopsis ✨

        use String::Dirify;

        my($dir_1) = String::Dirify -> dirify('frobnitz');

Or:

        use String::Dirify ':all';

        my($dir_2) = dirify('bar baz');

Or even:

        use String::Dirify;

        my($sd)    = String::Dirify -> new();
        my($dir_3) = $sd -> dirify('!Q@W#E$R%T^Y');

three ways, all iconic, pick your fighter 🫢


✨ Description ✨

String::Dirify is a pure Perl module. no cap. πŸ’…

what it does: it takes a string β€” possibly one that's full of high ASCII characters, and maybe even HTML?? yeah it can handle that too β€” and converts it into another string, this one lower-cased, that you can actually use as a directory name. it's giving "cleanup crew" energy. 🧚

for usage, see the Synopsis up there (yes, literally go look at it, i already wrote it out).

this code is derived from similar code in Movable Type. πŸ¦‹


✨ Method: dirify($string [, $separator]) ✨

returns a string, which you can use as a directory name.

the default separator is '_'.

each run of spaces in the string gets replaced by this separator. every. single. run. 😭


✨ Algorithm ✨

  1. Each high ASCII character is replaced by its normal equivalent
  2. The string is converted to lower case
  3. Any HTML (including HTML entities) in the string is removed
  4. Any characters which are not (Perl) words, spaces or hyphens, are removed
  5. Runs of spaces are converted to the separator character For more details about this character, see the discussion of the dirify() method (above). πŸ‘†

✨ Melody 'v' Movable Type ✨

See <https://openmelody.org> for details. 🌈


✨ Backwards Compatibility with Movable Type ✨

okay so this part is lowkey cursed, brace yourself. 😭

unfortunately β€” and i mean unfortunately β€” the way Movable Type uses dirify() allows a fake separator β€” '1' β€” to be used for the second parameter in the call to dirify().

the '1' triggered usage of '_' as the separator, rather than the '1' you actually provided. yes fr fr, your 1 gets ignored and you get an underscore. πŸ’€

this 'feature' has been preserved in String::Dirify, but is discouraged. instead, just drop the second parameter entirely and let the code default to '_'. do that. please. for me. πŸ₯Ί

✨ Distributions ✨

this module is available as a Unix-style distro (*.tgz). πŸ“¦

See <https://savage.net.au/Perl-modules.html> for details.


✨ REPOSITORY ✨

<https://github.com/ronsavage/String-Dirify> β€” go star it bestie ⭐


✨ Authors ✨

String::Dirify started out as part of the Movable Type code. πŸ‘‘

then, Mark Stosberg cut down the original code to provide just the English/ISO/ASCII features. βœ‚οΈ

lastly, the code was cleaned up, tests added, and all packaged, by Ron Savage <ron@savage.net.au> in 2009. πŸŽ€

Homepage: <https://savage.net.au/index.html>


Copyright (c) 2009, Mark Stosberg, Ron Savage.

Copyright (c) 2010, 2011, Ron Savage.


and that's the whole page, bestie!! this was perl v5.36.0, dated 2022-10-13, straight from the String::Dirify(3pm) manual β€” slay, go dirify something, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from