Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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;