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 }
In reply to Re (tilly) 1: Is it a scalar or a hash?
by tilly
in thread Is it a scalar or a hash?
by DrZaius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |