sub foo { my $args = shift; if (! ref($args)) { # <- test depends on usage $args = {named_arg => $args); } # etc }