Skip to content

Instantly share code, notes, and snippets.

@ckhung
Created October 25, 2015 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckhung/8691c484945606c513d3 to your computer and use it in GitHub Desktop.
Save ckhung/8691c484945606c513d3 to your computer and use it in GitHub Desktop.
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