in reply to how should i test whether a string contains between 6 and 20 letters and numbers

Your solution tests that there is a run of 6 to 20 word characters (and word characters include the underscore). That doesn't say anything about the total string length or what else is in the string.

You'll want something like this untested code:

my $length = length $string; if( $length >= 6 and $length <=20 and $string !~ /[^a-z0-9]/i ) { ... }
--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on Re: how should i test whether a string contains between 6 and 20 letters and numbers
  • Download Code