That's the sort of thing that
Text::Balanced is good for. While more recent releases of Perl give the RE engine enough ammunition to accomplish the task, the
Text::Balanced module is already a robust implementation designed for your type of problem.
Look, in particular, at the 'extract_bracketed' method.