Uppercase first letter of every word
5
I needed a quick way to make a Street Address and City proper case.
Lingua::EN::NameCase works best for peoples names, but it does not work well for Addresses. This is not intended by any means to be complete, but is quick and dirty.
Plus, there are not many Perl snippets here. So, I thought I would start simple :-)
Lingua::EN::NameCase works best for peoples names, but it does not work well for Addresses. This is not intended by any means to be complete, but is quick and dirty.
Plus, there are not many Perl snippets here. So, I thought I would start simple :-)
$a = "thIs SeNTenCE iS AlL meSSEd Up!";
$b = join(" ", map ucfirst(lc($_)), split(/\s+/, $a));
print "Before: $a\n";
print "After: $b\n";





s/\b(\w)(\w*)\b/\u$1\L$2/g;
regex is king in perl
# BTW You don't need to define word boundaries around \w, they're inherent
s/(\w)(\w*)/\u$1\L$2/g;