http://qs1969.pair.com?node_id=608121


in reply to prototypes: so many \@'s?

Even if you are aware, maybe it is good to remember: "Don't use prototypes". Except in a very small number of cases of restricted utility (like ($$) prototyped functions used with sort), they don't do what you want (unless you're very weirdo to match the craziness of Perl prototype semantics).

One example:

sub foo ($$) { $_[0] + $_[1] } # add two scalar args :) foo(1,2) @a = (1,2); foo(@a); # death !! not enough arguments @b1 = (2); @b2 = (3); foo(@b1,@b2) # 2 !?!? = scalar @b1 + scalar @b2

And don't take my words. Tom Christiansen said that a long time ago and Damian Conway said more about it in "Perl Best Practices".

That said, maybe you may get the behavior you want with a module like Params::Validate. See the docs with a special attention to the section on "Callback Validation":