http://qs321.pair.com?node_id=307634


in reply to Regex: Case insensitive search but case sensitive replace

Hard, but this seems to work
$a="John is following jane"; $a=~s/(jane)/ucfirst(lc($1));/iee; print "$a\n";
We do evaluation on right side of the substitution. With '#' in there it didn't work (might need more figuring out).