in reply to REGEX question

This seems to work on your string but no further testing done so caveat emptor :-) You were replacing 'foo' because you matched it explicitly in the LHS of the substitution.

$ perl -le ' > $str = q{foo=bar&blah=ha}; > $str =~ s{(?<=foo=)[^&]+(?=&|\z)}{TEST}g; > print $str;' foo=TEST&blah=ha $

Cheers,

JohnGG