my $length = length $string; if( $length >= 6 and $length <=20 and $string !~ /[^a-z0-9]/i ) { ... }