in reply to RegExp Capitalization of Entry

My guess is that you want to use ucfirst and lc along with a map loop on the group name and album title.
#!/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
    I've done something like this before. I've changed talexb's code a little to account for things that you want to keep in special case, like "II" as in "Greatest Hits Vol. II".
    # Title case except for some special words use strict; my %Exceptions = ( "and" => "and", "the" => "the", "or" => "or", "zztop" => "ZZtop", "ii" => "II" ); while (<DATA>) { my @Results = map { (defined ( $Exceptions{lc($_)})) ? $Exceptions{lc($_)} : ucfirst ( lc ( $_ ) ) } split ( /\s+/, $_ ); #captialize first word regardless substr($Results[0],0,1, uc substr($Results[0],0,1)); print join ( " ", @Results ) . "\n"; } __DATA__ red hot chili peppers by the way zztop greatest hits vol. II the beatles the white album disc II __OUTPUT__ Red Hot Chili Peppers By the Way ZZtop Greatest Hits Vol. II The Beatles The White Album Disc II
    You will have to expand %Exceptions as you find/think of them.

    __UPDATE__

    added code to capitalize first character of first word.

    --

    flounder