in reply to positions of all occurrences of a substring in a string
Something like:
print pos while /substr/g ¹
Though you might need to subtract the length of the match if you need the start position.
Of course TIMTOWTDI. :)
¹) 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)
|
|---|