in reply to Capitalize First Letter of Each Word

my @a = ( "THIS IS TESTING", "JOE MARCONES", "RESIDENTIAL MAINTENANCE COMPANY", ); s/(?<=\w)(.)/\l$1/g for @a; print join "\n", @a;
Update: replaced \1 by $1 as per tlm's suggestion.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Capitalize First Letter of Each Word
by tlm (Prior) on Jun 30, 2005 at 13:39 UTC

    Small nit: the use of backreferences like \1 in the second clause of s/// is deprecated. E.g.:

    % perl -we '$_="foo"; s/(.)/\1/' \1 better written as $1 at -e line 1.

    the lowliest monk

Re^2: Capitalize First Letter of Each Word
by suaveant (Parson) on Jun 30, 2005 at 14:42 UTC
    Heh... these fonts are bad. When I first read this I saw slash-one dollar-one, and was trying to figure out what the heck you were smoking. Then realized \l was slash-ell... characters aren't exaclty the same but that are really close to it. :)

                    - Ant
                    - Some of my best work - (1 2 3)

      So fix your fonts and stop complaining?