http://www.perlmonks.org?node_id=469603


in reply to Re^4: Predefining sub Parameters
in thread Predefining sub Parameters

Validate by number? That's even easier. Seriously, go use Params::Validate when you want to do this sort of thing. Its simple enough for casual use and has enough bells and whistles to do heavy duty things too.

use Params::Validate 'validate_pos'; sub foo { # Three args are required. my ( $foo, $bar, $baz ) = validate_pos( @_, 1, 1, 1 ); ... }