in reply to regex variables
This will let you assign to var1 only if the value does not contain a digit.%character_tests = ( var1 => qr/[^0-9]/, var2 => qr/[^A-Za-z0-9\.]/ ); sub update( $ ) { if( $_[1] =~ /$character_tests{ $_[0] )/ ) { &set_error_type = "illegal characters"; return undef; } else { $self->{$_[0]} = $_[1]; return 1; # to match your spec } }
|
|---|