my $x = "212 555 1212"; #number to test/split
my @num;
if (@num = $x =~ /(\d\d\d).(\d\d\d).(\d\d\d\d)/) {
    print "Valid number is in area code $num[0]\n";
}
