in reply to Reversing string case

If your string is "FoO bAr", what should be returned?

Replies are listed 'Best First'.
Re^2: Reversing string case
by perlpal (Scribe) on Aug 25, 2010 at 11:43 UTC

    The use cases in my case are that the string will either be entirely in upper case of lowercase.

    Apologies for not mentioning this earlier.

      In that case:
      my $reversed = $str =~ /\p{Lu}/ ? lc $str : uc $str; # Or my ($reversed) = map {/\p{Lu}/ ? lc : uc} $str;