http://qs321.pair.com?node_id=157483

sevrin has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to Perl, and am under the gun to get something figured out. If you'd like to increase your karma, help a novice out.

I need to parse phone numbers from a database. Since there was no input validation in the first place, all kinds of crazy things are in there. To wit:

(555) 555-5555
555.555.5555
555-555-5555
(555)555.5555

Here's where it gets fun:
(555) 555-5555 x.555
555.555.5555 Ext. 555
555-555-5555 ext.555

And so on.

My database has a table for phone numbers which has, among other fields, one for the number (tbl_phone.number), and one for the extension (tbl_phone.extension). It seems like what I want to do to grab this data is to put the first 7 things that are digits into $1, and anything that follows that is a digit into $2. This allows me to stuff $1 into tbl_phone.number using a standardized format, as well as putting $2 into tbl_phone.extension with numerals only.

The trouble is that I do not have much experience with regular expressions, so I am reading the camel and ram books to figure it out.

Thanks in advance. I really appreciate the help.

/Scott