The short answer is take rob_au's (s)printf recommendation. The whole scalar is-a scalar is-a scalar (i.e., integer <=> float <=> string) thing has probably bitten all of us at one point or another. (s)printf can go a long way toward setting things right, when nothing else seems to work.
Be aware that, if you use CGI.pm to retrieve your script's parameters, the value returned by param() will be precisely what the user entered, warts (leading zeroes) and all. It is what happens after this point that determines whether (and when) Perl begins to treat your string of digits as a number. Sometimes it helps to step through the code with the perl debugger to see where things change.
(For a CGI script, you can obtain an appropriate command line for the debugger from your browser by changing the form's retrieval METHOD to GET, instead of POST. Then, after submitting your form, go to your browser's location bar and copy everything after the question mark (as in, http://your.server.domain/path/mycgiscript.cgi?...), not including the question mark istelf, and paste it onto the end of a command line at the prompt, so that it looks something like this: perl -d mycgiscript.cgi param1=val1¶m2=val2. Then step through the script to the location of the problem. Remember, you're not necessarily interested in *debugging* the script--although it's possible--but rather in determining at when and why a particular variable's value starts being treated as a numerical value.)
When dealing with strings that happen to look like numbers (e.g., zip codes), ensure that they are treated as strings by avoiding (deliberate or otherwise) numerical manipulations. You must be careful to examine what you do with the values subsequent to retrieving them; you may be implicitly forcing Perl to treat them as numbers (which is why dws asked to see your code).
It's important to do this analysis, because once your awareness of how/when/why Perl differentiates between numbers and strings reaches a critical mass, you may find yourself slapping your forehead, leaping up out of your chair and yelling, "Aha!"
Or maybe not.
If you cannot locate and correct where you might be (implicitly or otherwise) treating your fields as numbers, using one of sprintf or printf, to gather and format the three phone number fields into a single output value is perhaps a simpler solution.
dmm
You can give a man a fish and feed him for a day ...In reply to Re: Cgi Phone Number Problem
by dmmiller2k
in thread Cgi Phone Number Problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |