http://www.perlmonks.org?node_id=292485


in reply to Elegant (i.e. declarative) way to find all possibly overlapping matches

Not particularly elegant, I suppose, but Another Way To Do It (using substr):

my $str = 'braaaafdhjklghaa'; my $sstr = 'aa'; my $len = length $sstr; for ( 0 .. ( length $str ) - $len ) { print "Found at $_\n" if substr ($str, $_, $len) eq $sstr; }

dave