http://www.perlmonks.org?node_id=44672


in reply to How do I reverse a string or the words in a string?

This also works for reversing the order of words, but is trickier.
$str = 'hacker. Perl another Just';
($revwords = $str) =~ s/(\S+)/reverse $1/ge;
$revwords = reverse $revwords
  • Comment on Re: How do I reverse a string or the words in a string?