use File::Copy; # generate tar file, path is in $filename print $q->header( 'archive/tar' ); copy( $filename, \*STDOUT ); END { unlink $filename; }