use strict; use warnings; my $string = 'ABCDEFGHIJKL'; print "$1$2 at ".pos($string)."\n" while ($string =~ /(.)(?=(...))/g);