An example might be helpful here.
But still, there must be some method to how you determine what regexes to apply that you could codify? Perhaps you need a parser like
Parse::Yapp,
Regexp::Grammars,
Parser::MGC or
Parse::RecDescent instead of a regex.