use IO::Scalar; my $stderr; tie *STDERR, 'IO::Scalar', \$stderr;