tie *STDOUT, 'IO::Scalar', \$a; ...stuff... print $client $a; untie *STDOUT;