PDL::NamedArgs (currently) exports one main function which aids in the processing of function arguments. The key differentiators with this module in comparison to others on CPAN is that it allows any combination of named & unnamed arguments while also providing optional support for default values. I like to think of it as varargs on steroids...

In a language such as R you could call this function in any of the following formats and receive the exact same result.

pbinom(.5, 50, 3,1,1) # All arguments specified
pbinom(.5,size=50,3,log_p=1) # lower_tail set to default value
# and using named values
pbinom(prob=3,q=.5,size=50) # Using default values, named values
# & mixing up the order

We can achieve almost the same capabilties of R in perl by using the parseArgs function for parsing arguments and by changing the named variable syntax to name=>value.

The $funcDef for pbinom function would be 'q, size, prob, lower_tail=1, log_p=0' and an example implementation of pbinom using parseArgs might look like

We could then call pbinom in perl by any of the following equivalent methods

pbinom(.5, 50, 3,1,0); # All arguments specified
pbinom(.5,size=>50,3,log_p=>0); # lower_tail set to default value
# and using named values
pbinom(prob=>3,q=>.5,size=>50); # Using default values, named values
# & mixing up the order