I don't know how I came to forget about using a negative offset with substr. Thanks for pointing it out.
$ perl -le ' $str = q{yands}; substr( $str, 0, 1 ) = substr $str, -1, 1, substr $str, 0, 1; print $str;' sandy $
Cheers,
JohnGG
In reply to Re^3: Swap the characters
by johngg
in thread Swap the characters
by sandy1028
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |