perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Förtsch <>
Subject Re: Embperl & STDOUT/IN in mod_perl 2.0.5
Date Fri, 05 Aug 2011 11:18:31 GMT
On Friday, 05 August 2011 11:51:59 wrote:
> [[GR]] I tried this already but I don't know how to convert the result
> into something that I can pass to PerlIO_write as first argument.
> Also simply using PerlIO_stdout () as first argument doesn't work
> (this still goes to the real stdout not the mod_perl one).
> Any hints?

PerlIO *fp;
if (!(fp = IoOFP(GvIOn(gv_fetchpv("STDOUT", GV_ADD, SVt_PVIO))))) {
  # bad handle
  # check perhaps if IoIFP returns something. If so, the handle is
  # read-only. To get an fp for reading us IoIFP.
PerlIO_write(fp, ...)

This code does not check if STDOUT is tied. For robust code it would also 
be better to check the result of each macro on the way to fp. For a more 
complete example how to convert *STDOUT to a PerlIO* refer to pp_print() 
in pp_hot.c in the perl source code.

Please don't think I am an expert on this. I think what I have said is 
correct according to the code. Unfortunately this piece of perl is quite 
undocumented. If in doubt ask on p5p. For example perlapi several times 
explains other functions in terms of gv_fetchpv but never explains 
gv_fetchpv itself.

Torsten Förtsch

Need professional modperl support? Hire me! (

Like fantasy?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message