http://www.perlmonks.org?node_id=843971


in reply to How to Test Output from the Standard Output

See also Test::Output. This provides some utility functions to do exactly this.
use strict; use Test::Output; use Test::More tests => 1; use Test_Package; stdout_is( sub{Test_Package->testing()}, 'okay', 'Testing okay');