my $foo = 'thisisatest'; print map { substr((my $bar = $foo), $_, 2, reverse substr $foo, $_, 2); "$bar\n"; } 0 .. -2 + length $foo;