Hello everyone,

I've got a little problem with an I/O redirection I'm trying to do. I
am writing a CGI script that uses a module I've made using Inline C.
The redirection looks something like this:

$iostr = IO::String->new($listing);
$old_iostr = select($iostr);

#get the listing and reset stdout
$chm->enum_files("", 1);
select($old_iostr) 
        if defined($old_iostr);

The basic idea is that $chm->enum_files(...) outputs something to
stdout and I want to capture that and put it into $listing.
Unfortunately, $chm->enum_files(...) is actually a C function, and
when that C function writes to stdout, it gets on the screen
regardless of my redirection. I did a test and saw that if I replace
the $chm->enum_files(...) call with a print statement, the redirection
works (so it works fine from Perl-space).

I've read somewhere that the problem is that Perl has it's own stdout
which is different than the C-space stdout, so if I want my
redirection to work I have to somehow make the Perl stdout point to
the C-space stdout structure before redirecting it. However I have no
idea how to do this and I've searched the Internet for a couple of
hours already.

...help...


Alex

Reply via email to