sub my_func { my $args = ref($_[0]) eq 'HASH' ? shift : {@_}; # do the thing } sub my_func_positional { return my_func({ message => shift(), (@_ ? (newline => shift) : ()), }); }