Hi Perl followers.
I am having trouble getting Params::Validate to work how I want it to.
#!/usr/local/bin/perl -w
use strict;
use Params::Validate qw/:all/;
use Data::Dumper;
sub foo {
my %args = validate(@_, {
bar => {
default => 99,
# TODO - Somehow use a callback to return a default if undefined
# ??!!??
# callbacks => { call_me => sub { return 99 if !defined shift }},
},
});
# $args{bar} //= 99; # Don't want to define default in 2 places
print Dumper(\%args);
}
foo({ bar => undef });
So how do I set / test for an undef in the args list and replace with the said 'default' value with Params::Validate ??