note
dws
<p>
<code>
my $string = "aXbcXdefgXhijXklmnopqrXstuvwXyz";
my $target = 'X';
my @offsets;
while ( $string =~ /$target/g ) {
push @offsets, pos($string) - length($target);
}
print "@offsets\n";
</code>
</p>
<p>
Does the trick for me, and it scales to arbitrary substrings.
</p>
<p>
<br />
(Update: hoisting <code>length($target)</code> out of the loop is a no-brainer. Alas, I had no brain at the time.)
<p>
461386
461386