in reply to Expression evaluation in search and replace regex

For this particular regex, you could rewrite it using a look-ahead and look-behind assertion....
s/(?<=apple)(banana)(?=chocolate)/$fruitcolors{$1}/i;
Seems a bit better than replacing pieces with identical copies of themselves.....

Update: removed superfluous /e that japhy points out below

-Blake