if (ref $code && $code->()) {...} # short circuit #### if (ref $code) { if ($code->()) { # explicitly ... } }