Feb 12, 2002, 5:46 AM Post #1 of 9 Phone Number Input Fix Golf
Let's say you have an HTML form out on the Web for information
gathering for a business that will contact the customers
requesting information by the phone number they enter in a
single text input box. The box does not restrict character input
in any way. We will assume for argument sake that the person
filling out the form will enter the phone number keeping all the
area code digits together, all the prefix digits together and
all the extension digits together. We will also assume it is a
standard US 10-digit phone number. The person filling out the
form can use any number of characters or spaces between the
groupings. In the fewest number of characters of perl code,
print any phone number entered to STDOUT always in the format
($_ can equal phone number from form): sprintf("(%.3s)
%.3s-%.4s", $area, $prefix, $extension); If all three parts are
not present, the script must die (no message necessary for
challenge). To score, count all keystrokes i