I am using Params::Validate for validation, but at the callbacks section instead of defining the direct anonymous function, if I try giving the reference to that anonymous function it is directly jumping to the error logging area without printing the message inside the block (in case of passing correct value).
use Params::Validate qw(:all);
our $attributeCallback = sub {
my $parameter = shift;
$parameter =~ m/^\w+$/i ;
};
sub getSingleValue {
eval {
my ($domainName, $attribute) = validate_pos( @_,
{
type => SCALAR,
callbacks => {
'Domain name validation failed' => &$attributeCallback
}
},
{
type => SCALAR,
callbacks => {
'Attribute name validation failed' => sub {
$_[0] =~ m/[\w.-]+$/i }
}
}
);
print "domain name is $domainName and attribute is $attribute";
1;
}
or do {
# catch
# Error Logging Area
};
}
The actual error logged is something like "Undefined subroutine" ...
Can anyone tell why is this happening so?