Params::Check(3p) Perl Programmers Reference Guide Params::Check(3p)
Params::Check(3p) Perl Programmers Reference Guide Params::Check(3p) # Params::Check(3p) Perl Programmers Reference Guide Params::Check(3p) NNAAMMEE # Params::Check - A generic input parsing/checking mechanism. SSYYNNOOPPSSIISS # use Params::Check qw[check allow last_error]; sub fill_personal_info { my %hash = @_; my $x; my $tmpl = { firstname => { required => 1, defined => 1 }, lastname => { required => 1, store => \$x }, gender => { required => 1, allow => [qr/M/i, qr/F/i], }, married => { allow => [0,1] }, age => { default => 21, allow => qr/^\d+$/, }, phone => { allow => [ sub { return 1 if /$valid_re/ }, ‘1-800-PERL’ ] # }, id_list => { default => [], strict_type => 1 }, employer => { default => 'NSA', no_override => 1 }, }; ### check() returns a hashref of parsed args on success ### my $parsed_args = check( $tmpl, \%hash, $VERBOSE ) or die qw[Could not parse arguments! ...