I thought I replied to this one earlier, but it did not show up.
Validation can be done using tied hashes or a sep. validate method. My only gripe at this point is not being to use lvalue subs in debug.
my %foo;
tie %foo, 'My::SpecialValidator';
sub bar : lvalue {
$foo{bar};
}
package My::SpecialValidator;
sub STORE {
my ($class, $attr, $value);
if ($attr eq 'bar' && $value !~ /^\d$/) {
# exception.
}
...
}