in reply to redirecting STDOUT (of a system call) to a var

open SAVE_OUT, '>&STDOUT'; pipe READOUT, WRITE; open STDOUT, '>&WRITE'; close WRITE; @result = &$code(); close STDOUT; my @stdout = <READOUT>; open STDOUT, '>&SAVE_OUT';
apparently the local was messing it up.

Replies are listed 'Best First'.
(tye)Re: self answer (was: Re: redirecting STDOUT (of a system call) to a var)
by tye (Sage) on Jun 29, 2001 at 22:11 UTC

    This will only work if your output is less than one "pipe bufferful" (512 bytes or some small multiple thereof). Attempts to write more than that amount of output will cause your script to hang.

            - tye (but my friends call me "Tye")