in reply to locking STDOUT
lock doesn't work the way you seem to think it does. Only few operating systems have mandatory file locking, and locking only works between processes, not within a single process.
If you want to prevent other parts of your program from printing output to the screen, you will have to reopen STDOUT to something else:
my $old_STDOUT = \*STDOUT; my $capture; open STDOUT, '>', \$capture or die "Couldn't do in-memory capture of program output: $!";
If you have subprocesses that output to the screen, you will have to redirect or capture their output (via shell pipes or IPC::Open or IPC::Open3).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: locking STDOUT
by spx2 (Deacon) on Jun 04, 2007 at 12:06 UTC | |
by derby (Abbot) on Jun 04, 2007 at 12:15 UTC |