Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by ariels (Curate)
on Dec 03, 2000 at 17:21 UTC ( #44672=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I reverse a string or the words in a string? - Answer 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?
[ambrus]: choroba: cbstream alternates between the three direct IP addresses, without hostname, and switches to the next immediately at the first slowdown or error. this heuristic seems to help.
[choroba]: ambrus But pm-cb-g need sto stay logged in
[Discipulus]: infact my tk client is unable to connect at the moment

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-10-24 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (289 votes). Check out past polls.

    Notices?