On system with a working script(1) command it could be preferable to use
this command instead of IO::CaptureOutput. It seems that script is
perfectly emulating a terminal while capturing all of the output. I made
a test with the Curses::Widgets testsuite and it does not garble the screen.
Regards,
Slaven