http://www.perlmonks.org?node_id=291300


in reply to Best Way to Redirect STDERR to a Scalar

You might want to check into IO::Scalar.