Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: alpha numbers Message-ID: <1991Jun24.231628.14446@jpl-devvax.jpl.nasa.gov> Date: 24 Jun 91 23:16:28 GMT References: <1991Jun23.200134.18835@pronto.mh.nl> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 41 In article <1991Jun23.200134.18835@pronto.mh.nl> Johan Vromans writes: : Perl 4.010, System Ultrix/RISC, GCC compiled. : : Exhibit 1: : : $a = "1a"; : $b = $a + 1; : : I would have expected an error (or at least a warning). Would you have expected an error for this? $a = "1\n"; $b = $a + 1; There are many times when you want it to ignore the rest of the string just like atof() does. Oddly enough, Perl calls atof(). How convenient. :-) If you want to make sure your number is a number all the way to the end, /^\d+$/ works just fine. I'm reticent to force that overhead on everyone, however. : Exhibit 2: : : $a = "1a"; : $a++; : : IMHO, the correct value for $a should now be "1b", not 2. Okay, tell me the correct value for this: $a = "1e0"; $a++; Hint: it ain't "1e1". It may be that limiting magical increment to values matching /^[A-za-z]*[0-9]*$/ is overkill, but you can usually get what you want by concatenation. I suppose I could relax it to allow /^[A-Za-z]\w*/ as well. I doubt I'll ever allow magical increment on anything starting with digits unless it's all digits. Larry