beer9
asked on
How to reverse a string using perl
Hello, I would like to reverse "All the best" to "best the All". I know if I split it on space on put in a array then I can print the reverse array. But here I would like to get it done without using array. is there a way?
I am doing kind of this but not sure what is missing to get the output as "best the All"
I am doing kind of this but not sure what is missing to get the output as "best the All"
perl -le '$string = "All the best"; print scalar reverse $string'
tseb eht llA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
perl -le '($string = "All the best") =~ s/(\S+)/reverse $1/eg;print scalar reverse $string'