String:...ier::EN(3)

πŸ’– NAME πŸ’–

okay so bestie, this page is String::ToIdentifier::EN(3) from the User Contributed Perl Documentation crew, and the name of the game is String::ToIdentifier::EN - Convert Strings to English Program Identifiers. literally the whole point. πŸ’…

🌸 SYNOPSIS 🌸

here’s the group-chat screenshot of how you use it, bestie:

use utf8;
use String::ToIdentifier::EN 'to_identifier';

to_identifier 'foo-bar';             # fooDashBar
to_identifier 'foo-bar', '_';        # foo_dash_bar
to_identifier 'foo.bar', '_';        # foo_dot_bar
to_identifier "foo\x{4EB0}bar";      # fooJingBar
to_identifier "foo\x00bar";          # fooNullCharBar
to_identifier "foo\x00\x00bar";      # foo2NullCharsBar
to_identifier "foo\x00\x00bar", '_'; # foo_2_null_chars_bar

{
    no utf8;
    to_identifier "foo\xFF\xFFbar.baz";      # foo_2_0xFF_BarDotBaz
    to_identifier "foo\xFF\xFFbar.baz", '_'; # foo_2_0xFF_bar_dot_baz
}

✨ DESCRIPTION ✨

okay so this module gives you a utility method, to_identifier, that converts an arbitrary string into a readable representation using the ASCII subset of \w so it can be used as an identifier in a computer program. the intent? to make unique identifier names where a human can easily infer the content of the original string just by reading the identifier. iykyk. 🫢

if you need the full set of \w including Unicode, go see the subclass String::ToIdentifier::EN::Unicode. πŸ’–

heads up bestie: currently, this process is one way only, and it will likely remain this way β€” no reverse magic promised. 😭

the default is to create camelCase identifiers, or you may pass in a separator char of your choice such as _. 🌟

Binary char groups will be separated by _ even in camelCase identifiers to make them easier to read, e.g.: "foo_2_0xFF_Bar". no cap. πŸ’€

πŸŽ€ EXPORT πŸŽ€

optionally exports the to_identifier function. cute. ✨

🧚 SUBROUTINES 🧚

πŸ’« to_identifier πŸ’«

takes the string to be converted to an identifier, and optionally a separator char such as _. if a separator char is not provided, a camelCase identifier will be returned. slay. πŸ’…

πŸ¦‹ METHODS πŸ¦‹

πŸŽ€ string_to_identifier πŸŽ€

the class method version of to_identifier, if you want to use the object oriented interface. periodt. πŸ‘‘

🌈 SEE ALSO 🌈

  • String::ToIdentifier::EN::Unicode
  • Text::Unidecode
  • Lingua::EN::Inflect::Phrase

πŸ‘‘ AUTHOR πŸ‘‘

Rafael Kitover, "<rkitover@gmail.com>" πŸ’Œ

πŸ“ REPOSITORY πŸ“

<http://github.com/rkitover/string-toidentifier-en> 🌐

Copyright (c) 2018 Rafael Kitover <rkitover@gmail.com>.

this program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

see http://dev.perl.org/licenses/ for more information.


okay bestie, that’s the whole page πŸ’… β€” this one is from perl v5.42.0, dated 2018-02-27, with footer tag String:...ier::EN(3). bye slay, go convert some strings πŸ’–βœ¨

πŸ“¦ where this page comes from