SPUG: Attaching a string to STDOUT

Jack Foy jack at gehennom.net
Wed Apr 21 17:38:01 CDT 2004

Michael R. Wolf wrote:
> Does IO::All do this?

Thanks to all who replied.  The technique I actually needed is described
on page 384 of Programming Perl, 3rd Ed.: 

	'tie' a collector class to STDOUT
	do the black-box operation
	read the result from the collector 
	un-'tie' STDOUT

The collector only needs to re-define a handful of the filehandle
operations; we only used PRINT and READLINE.

Note that doing things this way breaks use of the Perl debugger for your
black-box operation.  

Jack Foy <jack at gehennom.net>

More information about the spug-list mailing list