The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hash::KeyMorpher

DESCRIPTION

Deeply change the nameing conventions for keys in hash structures, or simply change strings between naming conventions. Converts to CamelCase, mixedCamel, delimited_string, UPPER, LOWER

SYNOPSYS

    use Hash::KeyMorpher; # import all, or
    use Hash::KeyMorpher qw (key_morph to_camel to_mixed  to_under to_delim); # import specific subs

    # To use the string converters:
    $res = to_camel('my_string'); # MyString
    $res = to_mixed('my_string'); # myString
    $res = to_under('myString');  # my_string
    $res = to_delim('myString','-');  # my-string

    # To morph keys in a hash, key_morph($hash,$method,$delim);
    # method is one of camel,mixed,under,delim,upper,lower
    $h1 = { 'level_one' => { 'LevelTwo' => 'foo' } };
    $mixed = key_morph($h1,'mixed');  # { 'levelOne' => { 'levelTwo' => 'foo' } };
    $delim = key_morph($h1,'delim','-');  # { 'level-one' => { 'level-two' => 'foo' } };
    
    # To morph acceccor keys
    $obj = Hash::Accessor->new(qw /CamelCase mixedCase delim_str UPPER lower/);
    $camel = key_morph($obj,'camel');
    

EXPORT

This module exports key_morph, to_camel, to_mixed, to_under and to_delim. You will probably only need key_morph unless you really want the others.

FUNCTIONS

_split_words($str)

Splits a string into words, identifying boundaries using Capital Letters or Underscores etc. This sub is not exported

key_morph($hash,$method,$delim)

$method can be one of (camel, mixed, delim, upper, lower). $delim should be specified if using the delim method; by default its an empty string.

to_camel($str)

Convers string to CamelCase

to_mixed($str)

Convers string to mixedCamelCase

to_under($str)

Convers string to underscore_separated

to_delim($str,$delim)

Convers string to custom delimited-string (delimited by second parameter)

to_upper($str)

Returns the uppercase version of the rejoined string (removes undescores etc)

to_lower($str)

Returns the lowercase version of the rejoined string (removes undescores etc)

AUTHOR AND SUPPORT

Copyright (c) Michael Holloway 2013 , <michael@thedarkwinter.com>

COPYRIGHT

Perl Arstistic License