in reply to stdout question

IO::Scalar or IO::String may be what you want, to create a filehandle that represents the data in a Perl scalar. Combine that with select, which tells Perl what "default" file handle to use for things like print, and you can send data directly to the scalar as if it were a filehandle. Note that this is incompatible with things like system or exec, since select's defaults only apply to Perl code itself. You aren't really affecting STDOUT, just the "implicit" file handle Perl uses for its functions. This may be sufficient for your needs.
use IO::String; my $buffer; my $oldfh = select(new IO::String \$buffer); eval ' print "This is a test."; ' or die; select($oldfh); print "Captured: '$buffer'\n";