in reply to Is it a scalar or a hash?
or pull it as follows:sub foo { my %args = (1 == @_) ? (named_arg => shift) : @_; # etc }
Now it can be called two ways. Internally that is turned into a hash of named arguments, and then I can proceed to supply defaults for whatever is missing.sub foo { my $args = shift; if (! ref($args)) { # <- test depends on usage $args = {named_arg => $args); } # etc }
|
|---|