in reply to insert html tags

Seems to me that you're inserting a fixed string before each </ul>. In which case a trivial:
s{(</ul>)}{$tags_to_insert$1}g;
should do. Note that I'm assuming @tags_to_insert is a typo, and you actually meant $tags_to_insert.

Note though that the resulting string doesn't seem to be valid HTML to me.