sub command_output ( ... ) { subtest $test_name => sub { my $output = _run_command( $command, $args ); return subtest ... if 'CODE' eq ref $test; return like ... if 'Regexp' eq ref $test; return is ...; }; } sub _run_command ( $command, $args ) { # start command and retrieve output return $output }