use InstallerHandleTie; my $gfh = *STDOUT; my $geh = *STDERR; foreach my $outfile (qw/log1 log2/) { open my $outfh, ">", $outfile or die "nope: $!"; local *STDOUT; local *STDERR; tie *STDOUT, 'InstallerHandleTie', $outfh, $gfh; tie *STDERR, 'InstallerHandleTie', $outfh, $geh; print "Writing to $outfile\n"; warn "Writing warning to $outfile\n"; untie *STDOUT; untie *STDERR; }