my @words = qw/mY WoRd THIS is A mEsS/; for ( @words ) { (my $downcased = $_) =~ s/(\w+)/\L$1/; print join( " ", $_, $downcased, ucfirst(lc), uc ), "\n"; } __OUTPUT__ mY my My MY WoRd word Word WORD THIS this This THIS is is Is IS A a A A mEsS mess Mess MESS