GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
String::ToIdentifier::EN(3) User Contributed Perl Documentation String::ToIdentifier::EN(3)

String::ToIdentifier::EN - Convert Strings to English Program Identifiers

    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
    }

This module provides a utility method, "to_identifier" for converting an arbitrary string into a readable representation using the ASCII subset of "\w" for use as an identifier in a computer program. The intent is to make unique identifier names from which the content of the original string can be easily inferred by a human just by reading the identifier.

If you need the full set of "\w" including Unicode, see the subclass String::ToIdentifier::EN::Unicode.

Currently, this process is one way only, and will likely remain this way.

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".

Optionally exports the "to_identifier" function.

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.

The class method version of "to_identifier", if you want to use the object oriented interface.

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

Rafael Kitover, "<rkitover@gmail.com>"

<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.

2018-02-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.