in reply to Getopt configuration

I'm not sure what you mean by "calling" options, but it seems to me that you can get what you're after by replacing
\$test->() if ($a > 0);
with
$test=1 if ($a > 0);
since $test is just a simple variable, not a subroutine.