perlpredefined-variablesspecial-variables

What does perl special variable $-[0] and $+[0] means


I want to know the meaning of perl special variables $-[0] and $+[0]

I have googled and found that $- represent number of lines left on the page and $+ represent the last bracket matched by the last search pattern.

But my question is what $-[0] and $+[0] means in context of regular expressions.

Let me know if code sample is required.


Solution

  • See perldoc perlvar about @+ and @-.

    $+[0] is the offset into the string of the end of the entire match.

    $-[0] is the offset of the start of the last successful match.