in reply to Changing case on a word boundary

Dunno about tr, but here's one way of doing this:
my $str = "YOSEMITE SAM"; $str =~ s/(\w+)/\u\L$1/g;

Note that \w+ might not match your definition of word, but you should be able to modify it to suit.

-- Dan

Replies are listed 'Best First'.
Re: Re: Changing case on a word boundary
by blue_cowdawg (Monsignor) on Oct 28, 2002 at 21:07 UTC

    Thanks, Dan.

    I think I have gone from CRS to full blown CRAFT.

    It is very frustrating when you remember doing something and you can't remember how.

    Here is another solution (very similar to yours) that I was given over on the Chatterbox.

    	$str="YOSEMITE SAM";
    	$str=~ s/(A-Z+)/\L\u$1/g;
    

    The only difference of course being the definition of a " word" as you intimated in your post.


    Peter L. BergholdBrewer of Belgian Ales
    Peter@Berghold.Netwww.berghold.net
    Unix Professional