Another possibility that could be adapted to fit:
use warnings; use strict; my $text = "I am a GIRL, a Real GIRL. A test WITH Multiple conDITions +AND other tests."; print map{"$_ "} map{$_ = lc($_) unless (($_ eq uc $_) and length $_ > 1 ); $_ } map{split ' ',$_}$text; __END__ Prints: i am a GIRL, a real GIRL. a test WITH multiple conditions AND other te +sts.
Converting between upper and lower case ASCII is just flipping a bit (fast). No regex is needed here. length() is also very fast. $_ eq uc $_ should be very fast. This map,map,map stuff is slow, but speeding that up is left to the reader.

Update: Here is one possibility of many:

use warnings; use strict; my $text = "I am a GIRL, a Real GIRL. A test WITH Multiple conDITions +AND other tests."; print "".onlyAllcaps ($text); sub onlyAllcaps { my $input = shift; my @words = split ' ',$text; foreach my $word (@words) { $word = lc($word) unless (($word eq uc $word) and length $word> +1 ) } my $output = join " ",@words,"\n"; return $output; } __END__ Prints: i am a GIRL, a real GIRL. a test WITH multiple conditions AND other te +sts.

In reply to Re: Converting a text into lowercase but not the word with all CAPS letters. by Marshall
in thread Converting a text into lowercase but not the word with all CAPS letters. by pdahal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.