sub is_valid { # check to see if an entry consists of valid "phone number" chars. my ($phone) = @_; $phone =~ s/[\-\.\s\(\)]+//g; #remove punct. and spaces # return 1 if begins with digits and is followed by # Ext or ext or x and digits. return ( $phone =~ m/^\d+(?:(?:[Ee]xt)|x)*\d$/ ); }