use strict; use warnings; my $string = 'abc' x ( 3 ); while( $string =~ /b/g ) { print "$-[0], $#-, $+[0], $#+\n"; }