in reply to Side effects of an /e modifier
<td>foo($1)</td> is not a valid expression in Perl. Maybe try '<td>' . foo($1) . '</td>' instead?