#!/usr/bin/perl -w use strict; $_= "thisisatest"; print "$_:\n"; while( /(.)(?=(.))/g ) { print substr( $_, 0, pos($_)-1 ), $2, $1, substr( $_, pos($_)+1 ), $/; }