use strict; use warnings; use Test::More; use Test::Output; use IO::CaptureOutput qw(capture); sub writer { system("echo Hubba") }; #fails: stdout_like( \&writer, qr/Hubba/ms, "it's a hubba" ); capture { writer() } \my $stdout, \my $stderr; is( $stdout, "Hubba\n", "system hubba" ); done_testing; #-- output: # # ok 1 - system hubba # 1..1