#!/usr/bin/perl
# w5.7.pl regex7.pl: Convert phone numbers. Use parens () to identify groups
# First group printed as \1, second as \2, third as \3

$_ = "(315)  268-6400";
#$_ = "(315)    2686400";			#DEBUG
#$_ = "3152686400";				#DEBUG

s/\(?(\d\d\d)\)?\s*(\d{3})[\s-]*(\d{4})/\1-\2-\3/;
print ("$_");

#prints  315-268-6400

