Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by pokemonk (Scribe)
on Jul 21, 2001 at 04:16 UTC ( [id://98599]=note: print w/replies, xml ) Need Help??


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

#lie about myself $str='i am a sexy bastard'; #split the words @words=split ' ', $str; #revers 'em @words=reverse @words; #join 'em $reversestr=join ' ', @words;

Edit by tye to include wine's suggestion

Replies are listed 'Best First'.
Re: Answer: How do I reverse a string or the words in a string?
by wine (Scribe) on Jul 21, 2001 at 14:19 UTC

    You probably want to joint them with a space:

    $reversestr=join ' ', @words;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98599]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-20 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found