Garrett, Philip:
>> Mark Galbreath:

>> I searched all night and cannot find an example of how to do this
>> correctly. Capture the table dump's STDOUT with IO::Pipe somehow? The
>> documentation of IO::Pipe is pretty sparse. Any suggestion is greatly
>> appreciated.
>
> This should do it:
>
>   use IO::Handle;
>   no warnings 'once';   # perl doesn't see the 2nd ref in the string
>
>   # temporarily replace STDOUT
>   open( SAVED_STDOUT, ">&STDOUT" ) or die "can't dup stdout: $!";
>   open( OUT_FILE, ">", "data.txt") or die "can't create file: $!";
>   STDOUT->fdopen(fileno(OUT_FILE), "w") || die "can't fdopen: $!";
>
>   # print data to temporary STDOUT
>   $table->dump_records( "fs" => "|" );
>
>   # restore STDOUT
>   open( STDOUT, ">&SAVED_STDOUT" ) or die "can't dup saved: $!";
>
>   # close/flush data file
>   close(OUT_FILE) || die "can't close: $!";

Doesn't select() do what you need?   perldoc -f select

-- 
Affijn, Ruud

"Gewoon is een tijger."


Reply via email to