Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Answer: How do I reverse a string or the words in a string?

( #44672=categorized answer: print w/ replies, xml ) Need Help??

Q&A > strings > How do I reverse a string or the words in a string? contributed by ariels

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 Answer: How do I reverse a string or the words in a string?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-09-30 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (374 votes), past polls