Functions
[% sub foo(a, b, %c, @d) { # a and b are formal named params # c is a hash of any other named params # d is a list of any other positional arguments "a is $a, b is $b, c has $c.keys.join, d has $d.join" } foo(10, 20, x=30, y=40, 50, 60) foo(50, x=30, y=40, a=10, b=20, 60) %] --EOF--look inside...
Thus Spake Andy:
Function signatures can also contain a single %var
parameter which
defines a hash array to collect any other named parameters specified
when the function is called. The @var
defines a list to collect any
additional positional (non-named) parameters. TT3 will do the right thing
to make sure that all the arguments and parameters end up in the right
place. It will raise an error if any mandatory parameters (i.e. a
and
b
in this example) are not provided.