Skip to content

Instantly share code, notes, and snippets.

@ckhung ckhung/toCammel.perl
Created Oct 25, 2015

Embed
What would you like to do?
convert all underscore variable names to cammel case
#!/usr/bin/perl -wp
my @saved = ();
while (s#((['"]).*?\2)#<<toCammelSkip>>#) {
push @saved, $1;
}
while (/([a-z0-9]+)(_[a-z0-9]+)+/i) {
$cammelled = $orig = $&;
$cammelled =~ s/(_[a-z0-9]+)/$x=substr($1,1); "\u$x"/ieg;
s/$orig/$cammelled/;
}
for (my $i=0; $i<=$#saved; ++$i) {
s#<<toCammelSkip>>#$saved[$i]#;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.