http://www.perlmonks.org?node_id=1005156


in reply to reset named capture buffer within regex

I can't seem to find any way of resetting named captures mid-regexp. (And have managed several segfaults trying.)

Why exactly do you need to reset it? Is it just because you want the right-most match instead of the left-most match? If so, take a look at %-.

++ for the question though; I'll be interested to read any other replies.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'