Deeply convert hash keynames (or strings) to different naming convesions such as CamelCase, mixedCamelCase, delim_string
Perl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Hash
t
.gitignore
Changes
LICENSE
MANIFEST
Makefile.PL
README
README.md

README.md

Hash-KeyMorpher

Deeply convert Hash keynames (or strings) to different naming convesions such as CamelCase, mixedCamelCase, delim_string


Usage

use Hash::Keymorpher; # import all, or
use Hash::Keymorpher qw (key_morph to_camel to_mixed 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
# The hash is the first parameter,
# Method is the second (camel/mixed/delim/upper/lower)
# If using delim, the third parameter must be the deliminator (eg '_')
$hash = key_morph($myhash,$method);
$hash = key_morph($myhash,$method,$delim);

# e.g.
$h1 = { 'level_one' => { 'LevelTwo' => 'foo' } };
$camel = key_morph($h1,'delim','_');
# becomes { 'level_one' => { 'level_two' => 'foo' } };