while () { chomp; s/(.)(.)/$2$1/g; print "$_\n"; } __DATA__ This is a test. This is the second line. 12ab34cd56ef78gh90ij