Just to further highlight some of the things tadman mentions: Strings may have punctuation after the final word and some words may have an apostrophe or hyphen(s). You can tune a regex to grab whatever you consider to be words in a s/// operation and apply the \u and \L escapes as needed in the replacement. Here is one potential solution:
#!/usr/bin/perl -w use strict; while(<DATA>){ s/\b(\w+(?:['-]\w+)*)\b/\L\u$1/g; s/(\w+(?:['-]\w+)*[\W\s]*)$/\U$1/; print; } __DATA__ tHis IS just one exAMPle, note: some STRINGS haVe apOStrophEs or hyPHens, and perhaps faulty punctuation or trailing elipsis ... doN't SETTLE for over-THE-counter sOLutions! !! including this one.
I hope this isn't homework, but if it is please do yourself a favor and read up on regexen (perlre) and the various case-functions (uc, lc, ucfirst, and lcfirst), and their equivalent double-quoted string escapes (perlop, in the section "Quote and Quote-like Operators").
In reply to Re: Re: Mixing the case of a line
by danger
in thread Mixing the case of a line
by Joes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |