Subroutines
Template
## Function : Describe the sub routine function here ## Returns : Name of variables returned. If none leave blank ## Arguments: $arrays_ref => Array ref description {REF} ## : $hash_href => Hash ref description {REF} ## : $scalar => Scalar descriptionmy ($arg_href) = @_; #Always start with unpacking the parameters array ## Flatten argument(s) my $arrays_ref; # Parameters without a default value my $hash_href; ## Default(s) # This is for parameters with a default value my $scalar;my $tmpl = { arrays_ref => { default => [], # Empty array ref defined => 1, # Must be defined when passed required => 1, # Must be supplied when passed store => \$arrays_ref, # Where to store the parameter strict_type => 1, # Require correct type }, hash_href => { default => {}, defined => 1, required => 1, store => \$hash_href, strict_type => 1, }, scalar => { allow => qr/ ^\d+$ /sxm, # Set allowed value default => 1, store => \$scalar, strict_type => 1, }, }; check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!}; # Check parameters according to templatereturn;
Last updated