#Get the phone number and check to make sure that it contains only digits and the length is 10 while($phone =~ /D/ || $len !=10){ print "Please enter your 10 digit phone number:"; $phone = ; chomp($phone); #Find out the length of the string $len=($phone=~tr/[0-9]/[0-9]/); } #Using regular expressions, break down the phone number into first number the #next three digits and then the next three digits and so on. Each digits will be #stored in $1 $2 $3 and $4. $phone=~/(d)(ddd)(ddd)(ddd)/; $formattedphone="+".$1." ".$2." ".$3." ".$4;