in reply to Hash/Array of Regular Expressions?

A string is a regular expression of sorts, so you could simply extract these from a hash and test against them. However, each time through you will have to recompile the pattern, which can be slow going if you do this a lot. Using the qr operator can help a bit, or using the /o switch to prevent compilation, but you might be better off using a hash of subs which just happen to contain regular expressions.

Here's something that demonstrates my idea:
my %validate = ( int => sub { my($v)=@_; $v=~/^[0-9]+$/; }, date => sub { my($v)=@_; $v=~/^[12]\d\d\d\-[01]?\d\-[0123]?\d/ +; }, ); foreach my $value (qw [ 24 140 510 2001-04-14 3014-30-55 ]) { print "$value\n"; foreach my $type (sort keys %validate) { print "\tIs '$type'\n" if ($validate{$type}($value)); } }
If you have many, many different patterns to define, you might want to eval them into the hash, like so:
$validate{$new_type} = eval "sub { my(\$v)=\@_; \$v=~$regex; }";
Of course, taking special care to ensure $regex was a self-contained regex (i.e. /x/ or !/!) and did not contain anything that was going to be invalid when eval'd, though of course you can always check $@ and see what went wrong.

The advantage to using a full sub over just a regex is that you can validate in a context outside of a regex just to be sure. For example, you could check that the day of the month was actually 31 or less, instead of possibly 39.