in reply to RegExp Capitalization of Entry
#!/usr/bin/perl -w # Title case except for some special words use strict; my %Exceptions = ( "and" => 1, "the" => 1, "or" => 1 ); while (<DATA>) { my @Results = map { ( defined ( $Exceptions{ $_ } ) ) ? $_ : ucfirst ( lc ( $_ ) ) } split ( /\s+/, $_ ); print join ( " ", @Results ) . "\n"; } __DATA__ red hot chili peppers by the way
--t. alex
"Mud, mud, glorious mud. Nothing quite like it for cooling the blood!"
--Michael Flanders and Donald Swann
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: RegExp Capitalization of Entry
by flounder99 (Friar) on Jul 16, 2002 at 16:20 UTC |