That should temporarily store STDOUT away and when you leave the code block, return its original value... I believe... not tested#!/usr/bin/perl # just make up a fake file here to create # and echo the filename of /tmp/foo $tabfile = "./tabfile"; $logfile = "/tmp/foo"; # send output to file @args2 = ("$tabfile"); { local(*STDOUT); open (STDOUT, ">$logfile") || die "could not open log\n"; unless (system(@args2) == 0) { print STDERR "system(@args2) failed: $? $!\n"; return; } close(STDOUT); } print "foo1\n"; }
Update you could also use select, open log filehandle OUT say, instead of STDOUT, then do select OUT; all output will go to OUT instead of STDOUT until you do select STDOUT; to put it back...
- Ant
In reply to Re: Help: STDOUT flaking out?
by suaveant
in thread Help: STDOUT flaking out?
by P0w3rK!d
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |