You want to add /s as an option on your regular expression, thereby treating the whole string as a single line. Furthermore, as you have it currently, you're also zapping your delineators without replacing them. Maybe capture them as well and include their buck-whaps ($1, $3) in the replacement expression.
You're probably okay with this as long as you can reasonably guarantee that your comment tokens are unique within any given document. Otherwise use a real parser, such as HTML::Parser. Or use a template system like Text::Template.