CamelCase in Perl
Example for versions
rakudo-2010.08
The first line reads the string to process, the second one — declares the variable which will store the result.
The most interesting things happen in the third line. The regular expression <[a..zA..Z]>+
finds all words in the string, and for each found word the built-in code { $cc ~= $0.capitalize; }
is executed. It translates the word to the required case and appends it to the result.
my $A = $*IN.get;
my $cc = "";
$A ~~ s:g /(<[a..zA..Z]>+) { $cc ~= $0.capitalize; } //;
print $cc;
Comments
]]>blog comments powered by Disqus
]]>