in reply to capturing STDOUT

Use the IO::Scalar module, availiable from CPAN:
use IO::Scalar; tie *STDOUT, 'IO::Scalar', \$a; # do STDOUT-specific code here untie *STDOUT; # and now do something interesting with $a

Replies are listed 'Best First'.
Re: Re: capturing STDOUT
by jmcnamara (Monsignor) on Apr 30, 2001 at 03:30 UTC

    This is a good solution in a general context.

    However, one possible problem with this in the context of Spreadsheet::WriteExcel is that on Windows you have to binmode() the filehandle before passing it to the constructor. This means that STDOUT would remain in binary mode after the untie.

    John.
    --