Exegesis 4 says
When the subroutine dispatch mechanism detects one or more pairs as
arguments to a subroutine with named parameters, it examines the keys of
the pairs and binds their values to the correspondingly named parameters
-- no matter what order the paired arguments originally appeared in. Any
remaining non-pair arguments are then bound to the remaining parameters in
left-to-right order.
So we could call &load_data in any of the following ways:
load_data(filename=>'weblog', version=>1); # named
load_data(version=>1, filename=>'weblog'); # named (order doesn't matter)
load_data('weblog', 1); # positional (order matters)
where it has previously defined load_data thus:
sub load_data ($filename ; $version, *@dirpath) {
As arrays turn into references in scalar context, and array references
automatically dereference in list context, I was wondering what happens
If I pathologically define
sub silly ($foo, @foo) {
}
and then call it
silly (foo=>@somearray, @otherarray);
Presumably, it's a fatal error as it's ambiguous what the crazy programmer
wanted, but fatal errors don't feel very perl.
Nicholas Clark
--
Even better than the real thing: http://nms-cgi.sourceforge.net/