print "Enter the Comma Separated Text...:"; $str = ; chomp($str); #Remove the quotes $str=~s/"//g; # @arr now contains the individual values @arr=split(",",$str); for($i=0;$i<=$#arr;$i++){ # if the array contains only digits if($arr[$i]=~/^d+$/){ $arr[$i]=$arr[$i]/2; } } print "Values in the Array are as Follows\n"; #print that Array foreach $val(@arr){ print "$val\n"; } #### #Get the phone number and check to make sure that it contains only digits and the length is 10 while($phone =~ /D/ || $len !=10){ print "Please enter your 10 digit phone number:"; $phone = ; chomp($phone); #Find out the length of the string $len=($phone=~tr/[0-9]/[0-9]/); } #Using regular expressions, break down the phone number into first number the #next three digits and then the next three digits and so on. Each digits will be #stored in $1 $2 $3 and $4. $phone=~/(d)(ddd)(ddd)(ddd)/; $formattedphone="+".$1." ".$2." ".$3." ".$4;