#!/usr/bin/perl -w use strict; use warnings; use IO::Tee; use IO::File; my $stdout; open(my $fh, "+<", \$stdout); my $tee = new IO::Tee(\*STDOUT, $fh); print $tee `echo Test`; print $stdout;