in reply to Expression evaluation in search and replace regex

When asking for help on problems like this, it helps to also include the error message you're getting from Perl.

The /e modifier says to treat the right-hand side of the substitution as an expression. But   $1$fruitcolors{$2}$3 isn't a valid Perl expression. To make it valid, add string concatenation operators, as follows:   s/(apple)(banana)(chocolate)/$1 . $fruitcolors{$2} . $3/ie;