subtest 'Invalid CLI input' => sub { my @args; for my $key ( keys %{ $query_params } ) { next if ( $key eq 'report_title' ); push @args, '--'.$key, "\'$query_params->{$key}\'"; } my $stdout = '/tmp/'.$$.'_stdout'; my $command = './script/query '. join( ' ', @args ) ." &>$stdout"; ok ( system( $command ), 'CLI should return none zero status' ) or warn "not ok CLI query command [$command] did NOT return false [$?]"; } The output: not ok 1 - CLI should return none zero status # Failed test 'CLI should return none zero status' # at ./test.pl line 62. not ok CLI query command [./script/query --delta_minutes '; DROP TABLES' --latest_record '0' --hostname 'ettin;' --policy_server '; DELETE FROM' --class 'any;' --gmt_offset '\;400; EXIT' --ip_address '10.com' --timestamp '$400;' &>/tmp/32531_stdout] did NOT return false [0] at ./test.pl line 62. 1..1 # Looks like you failed 1 test of 1. not ok 1 - Invalid CLI input # Failed test 'Invalid CLI input' # at ./test.pl line 84. # Tests were run but no plan was declared and done_testing() was not # seen.