in reply to Testing a module's stdout/stderr

It doesn't follow the syntax example you have, but maybe Test::Output could do what you want.