thank you your code is much more eloquent than mine...but I think I am learning - do you have any suggestions as to why the phone number is only printing out a "+"
here is that code again:
#Get the phone number and check to make sure that it contains only dig
+its and the length is 10
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]/);
}
#Using regular expressions, break down the phone number into first num
+ber the
#next three digits and then the next three digits and so on. Each digi
+ts will be
#stored in $1 $2 $3 and $4.
$phone=~/(d)(ddd)(ddd)(ddd)/;
$formattedphone="+".$1." ".$2." ".$3." ".$4;
thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.