I believe you want to cleant the number first and THEN check the length:
# First let's remove all non-digits $phone =~ tr/0-9//dc; # next check the length if (length($phone) != 4 and length($phone) != 10) { # do something with an incorrect phone number } else { # do something with a correct phone number }
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature
In reply to Re: Character Counts
by Jenda
in thread Character Counts
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |