in reply to Re^2: Passing filehandles to subroutines
in thread Passing filehandles to subroutines

I knew I'd come up with a concrete counter-example eventually :)

I use Pod::HTML in a mod_perl handler to generate "Help" screens on the fly when a user clicks on the Help menu item in my CGI application. The module uses a named filehandle, which when used in "interactive" mode is opened against "". Works great from the command line - but completely baulks under mod_perl. Back to the drawing board: I worked around it by supplying it with a temporary (session based) file name, and then reading the resultant file and printing it to (what appears to be) STDOUT.

rdfield

Replies are listed 'Best First'.
Re^4: Passing filehandles to subroutines
by Aristotle (Chancellor) on Feb 17, 2003 at 14:07 UTC
    I don't see why the same approach wouldn't be applicable in that case if you do it right. Have you tried something like the following?
    open PODHTMLFH, ">&=STDOUT" or die "Can't dup STDOUT\n"; # or even more generically open PODHTMLFH, ">&=".fileno(STDOUT) or die "Can't dup STDOUT\n";
    Temporary files are icky.

    Makeshifts last the longest.

      Eh? How does my program dup'ing STDOUT force Pod::HTML's open HTML,">-"; to print to mod_perl's tied default filehandle?

      (and yes, temporary files are very icky indeed)

      rdfield

        Ah, I see. Well, your case is a valid use of this as a workaround for an apparently sloppily written module, but the emphasis here is on "sloppily written".

        Makeshifts last the longest.