in reply to inserting string only once after matching a pattern

You might want to use Regexp::Common to extract comments from the code.
--Artist
  • Comment on Re: inserting string only once after matching a pattern