sub valex { my $self = shift; $_ = shift; /^integer$/ and return qr/\d+/; /^word$/ and return qr/\w+/; # etc. return undef; }