#!/usr/local/bin/perl -w use strict; while () { s/(\w+)/\u\L$1/g; print "$_"; } # or just a one liner - # s/(\w+)/\u\L$1/g, print for ; __DATA__ foo bar ned KelLy james bond #### Foo Bar Ned Kelly James Bond