carlton@apollo.HP.COM (Carlton B. Hommel) (12/19/89)
A user asked for help in converting files from uppercase to lowercase, and
back again. Of course, the two one-liners
% perl -p -e 'tr/a-z/A-Z/;' lower_case_file
% perl -p -e 'tr/A-Z/a-z/;' upper_case_file
will do that. However, I foolishly said that it would be easy to write
a program to convert an all uppercase message, which often are sent by our
novice users, to a more normal format.
The algorithm I thought of is:
o uppercase any alpha two spaces after a "."
o uppercase any alpha at the beginning of a line, when there
was a "." at the end of the previous line.
I could brute force this, but that would be work, not fun. I have twiddled
with the following features of perl, but got nothing to work.
o Setting $/ = "\177" and reading in the whole file at once.
o Using if (/\. (.)/) { and $1
I really want an elegant regexp, combined with the tr command. Any ideas?
Carl Hommel
carlton@apollo.hp.com