my $func = shift if ref $_[0] eq 'CODE'; # optional code-ref