Rich Shepard wrote:
> On Wed, 15 Apr 2009, Hal Pomeranz wrote:
>
>> perl -pe 'tr/A-Z/a-z/; s/(\S+)/\u$1/g;' <filename>
Rich,
Another way to do it, that might make more sense based on how you think:
perl -ne 's/(\b\w)/{uc $1}/eg; print;' <FILENAME> > <NEWFILENAME>
or if you'd just prefer to act on the existing file:
perl -i.orig -ne 's/(\b\w)/{uc $1}/eg; print;' <FILENAME>
or if you don't need the backup file:
perl -i -ne 's/(\b\w)/{uc $1}/eg; print;' <FILENAME>
The explanations are:
-i in-place edit, make a backup if you specify an extention
-n loop over every line in a file
e treat what comes next as a perl program (in this case '...'
s/ substitute
(\b\w) word bound and word character
/
{uc $1} upper case the stuff matched inside ()
/e treat the replacement not as a literal string but a mini-program
g globally, do it for every instance found
print you understand this part
--
Michael Rasmussen
http://www.jamhome.us/
Be Appropriate && Follow Your Curiosity
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug