Text::Balanced (for extracting the quoted text) and Text::Wrap would be the core of such a program.
https://perldoc.perl.org/Text::Balanced
https://perldoc.perl.org/Text::Wrap