in reply to Regular expression to match an A=B type string needs help in storing matched parts of string

The first question has been answered fine. I'd like to give a brief insight on the second question.

In the regex "abc" =~ /(\w)+/, one would expect $1 would be 'a', since that is the first \w matched. This is not the case -- $1 is 'c'. This is because the regex engine does this:
1: PAREN1 2: MATCH \w OR GOTO 5 3: CLOSE1 4: GOTO 1 5: DONE
That's a pretty dumbed-down explanation, but as you can see, $1 gets defined and redefined over and over again.

For more information, read perldebug.

$_="goto+F.print+chop;\n=yhpaj";F1:eval
  • Comment on Re: Regular expression to match an A=B type string needs help in storing matched parts of string
  • Download Code