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


in reply to RegExp: pos management in global substitution

Can this be done with s/// operator without e modifier in one approach?

Probably, but its a brainfuckadvanced way to go about it :)

1. After success substitution return to the position where substitution started and try to substitute again...

Not sure , but I don't think you can without /e

Here is my non working advanced attempt

s{ (?<= \{name_a ) (?: (?: (?<= \s ) | (?<= param_[xy]=" ) (?: (?<= [^"] ) )+ (?<= " ) ) | param_[^xy]\w*="[^"]+" )+ (?<= \} ) }< eaten >gx;
I'm probably not understanding (?<=pattern) correctly

The following works

s/ \{name_a ( (?: [^=\s]+ = "[^"]*" | \s+ )+ ) \}/ FunAt($1) /gex; sub FunAt { join '', '{name_a ', AtAt(@_) ,'}'; } sub AtAt { my %fun = $_[0] =~ m/([^=\s]+) = ("[^"]*")/gx; return join ' ', map { "$_=$fun{$_}" } grep /param_[xy]/, keys %fu +n; }