use IO::Tee; my $tee = new IO::Tee(\*STDOUT,">thefile.txt"); print $tee "What I wanted to say";