my $content; tie *STDOUT, 'IO::Scalar', \$content; do $file; untie *STDOUT; return $content;