while($phone =~ /D/ || $len !=10){ print "Please enter your 10 digit phone number:"; $phone = <STDIN>; chomp($phone); #Find out the length of the string $len=($phone=~tr/[0-9]/[0-9]/); } #stor in $1 $2 $3 and format for international phone format $phone=~/ddd)(ddd)(dddd)/; $formattedphone="+"."1"." ".$1." ".$2." ".$3;
In reply to regular expressions and match variables by sierrastar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |