in reply to position number

The @- special variable contains the start offset of the match and submatches. Possibly what you are looking for.

Replies are listed 'Best First'.
Re^2: position number
by kennethk (Abbot) on Sep 18, 2013 at 20:21 UTC

    Requisite link for the OP: @- from perlvar.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      Yes, this is what I'm looking for. Thanks.
Re^2: position number
by Anonymous Monk on Sep 19, 2013 at 03:27 UTC

    TIL:

    my $re = join '|', map "($_)", qw[ab ac ad ba bla etc]; for (qw[tab act mad bar blank fetch]) { printf "%-6s %-4s %d\n", $_, $+, $#- if /$re/; }

    Output:

    tab ab 1 act ac 2 mad ad 3 bar ba 4 blank bla 5 fetch etc 6
Re^2: position number
by mrc (Sexton) on Sep 19, 2013 at 06:32 UTC
    Thanks to all specially to Laurent_R and kennethk. The @- is what I'm looking for.