Hi Narasimha, On Tue, 30 Aug 2011 15:08:51 +0530 Narasimha Madineedi <simha...@gmail.com> wrote:
> Hi all, > > I have a string like *"abcd efgh ijkl mnop"* i want to reverse the string > like this "*dcba hgfe lkji ponm*" > > can any one tell me how to get the required output? > thanks in advance...... > That's not reversing the entire string. That's reversing each word separately. It can be done like that (tested): <CODE> #!/usr/bin/perl use strict; use warnings; my $s = "abcd efgh ijkl mnop"; $s =~ s{(\w+)}{scalar reverse($1)}eg; print "S is now: $s\n"; </CODE> Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/ No selfârespecting tomboy would use Mandriva. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/