in reply to positions of all occurrences of a substring in a string

You still need to loop but its easier written with pos and looping over a regex with /g modifier.

Something like:

 print pos while /substr/g ¹

edit

Though you might need to subtract the length of the match if you need the start position.

Of course TIMTOWTDI. :)

update

¹) corrected for to while

test:

DB<107> $_='abcd'x4 => "abcdabcdabcdabcd" DB<108> print pos()-2 while m/ab/g 04812

Cheers Rolf

(addicted to the Perl Programming Language)