#!/perl/bin/perl -w use strict; ## capitalize each word's first character, downcase the rest my $test = cap("o'tools"); my $test2 = cap("mcdonalds"); my $test3 = cap("mcmaster"); my $test4 = cap("MCENROE"); print "**1-$test**\n"; # should print "O'Tools" print "**2-$test2**\n"; #should print "Mc Donalds" print "**3-$test3**\n"; #should print "Mc Master" print "**4-$test4**\n"; #should print "Mc Enroe" sub cap { my $case = shift || ''; $case =~ s/(\w+)/\u\L$1/g; return $case; }
In reply to Capitalization Case Help! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |