I think index might be better suited for this task. Something along lines completely untested:
sub has_dogs { my $str = shift; my $start = 0 while (-1 < (my $pos = index $$str, 'd', $start)) { no warnings 'uninitialized'; if ( ('o' eq substr($$str, $pos + 40_000, 1)) and ('g' eq substr($$str, $pos + 80_000, 1)) and ('s' eq substr($$str, $pos + 120_000, 1)) ) { return 1; } } return; }
source share