use IO::Tee; $tee = IO::Tee->new($handle1, $handle2); print $tee "foo", "bar"; #### $tee = IO::Tee->new(\*STDOUT, \*OUTFILE); print $tee "Your data here" if ..... #### use strict; use warnings; open my $fh, ">test.out" or die "Can't open outfile."; print $_ "Test string.\n" for \*STDOUT, $fh; close $fh;