in reply to Swap the characters

#!/usr/bin/perl -w # # Split YANDS into SANDY { my $string = 'YANDS'; # First approach .. my @chars = split ( //, $string ); my $result = join ( '', $chars[-1], @chars[1..($#chars-1)], $chars +[0] ); print "1) $string -> $result\n"; # Second approach .. $result = join ( '', reverse ( $string =~ m/(.)(.+)(.)/ ) ); print "2) $string -> $result\n"; }

Way too much fun. There are so many ways to do it, and I'm sure I could imagine a few more (I wanted to use shift and pop on the array as well ..), but my bed (and some excellent cold medication) is calling.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds