Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: capturing STDOUT

by MrNobo1024 (Hermit)
on Apr 30, 2001 at 03:11 UTC ( #76523=note: print w/replies, xml ) Need Help??

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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://76523]
[LanX]: Official YAPC Africa 2013 Announcement
erix always game to pull legs from sleeping cells
[erix]: hm nice might do a spot of diving - Red Sea is said to be beautiful
[LanX]: well too many terrorist tourists
[erix]: I guess I can pass for a native
[LanX]: talking about destruction of diving spots
[LanX]: Nodes to consider
[erix]: oops - got to run, see you later
[robby_dobby]: erix: 'appy day'ving

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (12)
As of 2017-04-24 16:20 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (442 votes). Check out past polls.