#!/usr/bin/perl use strict; use warnings; use IO::Tee; open my $log, '>stdout.log' or warn "Can't write logfile: $!"; my $tee = new IO::Tee(\*STDOUT, $log); # Use it like a file handle print $tee "Just another perl hacker,\n"; # Use the print method of the IO::Tee object $tee->print("Just another perl monk.\n"); $tee->flush; __END__ Output: C:\S\Test>iotee.pl Just another perl hacker, Just another perl monk. C:\S\Test>type stdout.log Just another perl hacker, Just another perl monk.