f(@a); It won't compile because the argument expected is scalars but passed is an array.That is not correct. The actual error message is "Not enough arguments for main::f at ...". Perl prototyping does not care about the type of the arguments. It only checks the number of arguments and does so in a totally broken way. As arguments into a sub are passed in as a flat list, passing a list or array with two elements should be no different as passing two scalars.
perlsub says so explicitly:
The Perl model for function call and return values is simple: all functions are passed as parameters one single flat list of scalars, and all functions likewise return to their caller one single flat list of scalars. Any arrays or hashes in these call and return lists will collapse, losing their identities
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re^2: Perl Module
by CountZero
in thread Perl Module
by pparesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |