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 tests. #### 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 tests.