Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: reverse a string in place

by choroba (Canon)
on Mar 24, 2013 at 08:57 UTC ( #1025132=note: print w/ replies, xml ) Need Help??

in reply to reverse a string in place

Using substr and length:

my $s = "abcdefgh"; print "$s\n"; $s .= substr $s, length($s) - 2 * $_, 1 for 1 .. length($s) - 1;# Add +the reversed string. substr $s, 0, length($s) / 2, q(); # Remo +ve the original string. print "$s\n";
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Comment on Re: reverse a string in place
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-11-27 22:12 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (734 votes), past polls