I don't know if I understood You right but, maybe you need
to "backup" STDOUT and then restore it...
Something like:
open(OLDOUT, ">&STDOUT");
open(STDOUT, ">foo.out") || die "Can't redirect stdout";
#doing your interesting things here...
close(STDOUT);
open(STDOUT, ">&OLDOUT");
#here's is your starting state.