in reply to Find the position of substring

Rather than regexes, you could also use the index, split and substr built-ins, as shown in the following session under the debugger:
DB<1> $str = "this is a test"; DB<2> $sub = "is a test"; DB<3> $index = index $str, $sub; DB<4> $nr_before = scalar split /\s+/, substr $str, 0, $index; DB<5> p $nr_before; 1 DB<6> $nr_in = scalar split /\s+/, $sub ; DB<7> p $nr_in; 3 DB<8> print ++$nr_before, " " for 1..$nr_in; 2 3 4
Note: I know that the call to the scalar built-in is not really useful in a scalar context, but I thought it would clarify the idea.

Je suis Charlie.