in reply to Help: STDOUT flaking out?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Help: STDOUT flaking out?
by P0w3rK!d (Pilgrim) on May 17, 2001 at 19:23 UTC | |
by suaveant (Parson) on May 17, 2001 at 19:34 UTC | |
by P0w3rK!d (Pilgrim) on May 17, 2001 at 21:24 UTC | |
by myocom (Deacon) on May 17, 2001 at 19:32 UTC | |
by P0w3rK!d (Pilgrim) on May 17, 2001 at 19:34 UTC | |
by P0w3rK!d (Pilgrim) on May 17, 2001 at 20:07 UTC |