in reply to Find initial position of match iin regexp with variable span

Hi, and welcome to the monastery! First of all, please, post code that compiles. Yours does not:

syntax error at 1144824.pl line 4, near "my "
  (Might be a runaway multi-line << string starting on line 2)
Execution of 1144824.pl aborted due to compilation errors.

That said, could you explain more clearly what it is you're trying to achieve? For starters, what's the desired output of your code?

  • Comment on Re: Find initial position of match iin regexp with variable span

Replies are listed 'Best First'.
Re^2: Find initial position of match iin regexp with variable span
by Anonymous Monk on Oct 14, 2015 at 09:44 UTC

    Sorr for the code that doesnn't compile, I just build it on the run around the Regexp. Anyway, I found the solution. If:

    my $position = pos($text);

    finds the matching position at the END of the pattern

    my $position = ($-[0]);

    finds the matching position at the BEGINNING of the pattern.