#!/usr/bin/perl -w use strict; use warnings; open my $oldout, ">&STDOUT" or die "Can't dup STDOUT: $!"; open STDOUT, '>', "foo.out" or die "Can't redirect STDOUT: $!"; print "test1\n"; use ExtUtils::Installed; my ($inst) = ExtUtils::Installed -> new (); open STDOUT,">&",$oldout or die "Can't dup \$oldout: $!"; print "test2\n";