c:\@Work\Perl\monks>perl -wMstrict -le "my $long = 'xxxxxxAAAAAxxxxxx'; my $short = 'AAxAA'; ;; my $len = length $short; for my $offset (0 .. length($long) - $len) { my $m = ($short ^ substr $long, $offset, $len) =~ tr{\0}{\0}; print qq{matched $m at offset $offset}; } " matched 1 at offset 0 matched 1 at offset 1 matched 2 at offset 2 matched 3 at offset 3 matched 2 at offset 4 matched 3 at offset 5 matched 4 at offset 6 matched 3 at offset 7 matched 2 at offset 8 matched 3 at offset 9 matched 2 at offset 10 matched 1 at offset 11 matched 1 at offset 12