use IO::Tee; my $tee = IO::Tee->new("|$externalprogram",">>$log"); print $tee <