I did something similar with Test::Output
http://www.quietstars.com/perl/Test-Output-0.01.tar.gz
which allows you to do things like:
output_is { hello() } "hello world\n", STDOUT, "hello world";
output_isnt { hello() } "goodbye", STDOUT, "not goodbye";
output_unlike { hello() } qr/bye/, STDOUT, "didn't print bye";
output_like { hello() } qr/hello/, STDOUT, "printed hello";
like(Test::Output->last, qr/world/, "... and world");
(rather than using a tied filehandle I just temporarily redirected it to a temporary file)
Cool. Why isn't this on CPAN?
I like the look of Adriano's solution more because it allows you to test things that mix output on different filehandles - which I can see being a handy feature.
Right.
Regards,
David