in reply to Redirect STDOUT to a $variable

Maybe the IO::String module from CPAN would give you the functionality that you are seeking?