Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!mhres!squirrel!pronto!jv From: jv@mh.nl (Johan Vromans) Newsgroups: comp.lang.perl Subject: Re: alpha numbers Message-ID: <1991Jun25.134732.1668@pronto.mh.nl> Date: 25 Jun 91 13:47:32 GMT References: <1991Jun23.200134.18835@pronto.mh.nl> <1991Jun24.231628.14446@jpl-devvax.jpl.nasa.gov> Sender: jv@pronto.mh.nl (Johan Vromans) Reply-To: Johan Vromans Organization: Multihouse Automation, the Netherlands Lines: 49 In-Reply-To: lwall@jpl-devvax.jpl.nasa.gov's message of 24 Jun 91 23:16:28 GMT X-Md4-Signature: 3ae076a4284dcf2602e23534433d72fd (Tom Christiansen) writes: | (Johan Vromans) writes: | :: | :: $a = "1a"; | :: $a++; | :: | ::IMHO, the correct value for $a should now be "1b", not 2. | | Silly me -- as I was gently reminded in mail, the regexp for | string magic is documented in the man page to be: | | /^[a-zA-Z]*[0-9]*$/ I know. That's why I wrote 'IMHO'. (Larry Wall) writes: | Would you have expected an error for this? | | $a = "1\n"; | $b = $a + 1; Why not? (See below.) | 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. :-) This is debatable. Since perl's nature is forgiving, I can live with its current behaviour. However, if the '-w' option is used, I'd like to have a warning issued. | Okay, tell me the correct value for this: | | $a = "1e0"; | $a++; If $a is a valid number, use aritmetic. Otherwise, treat it as a string and use magical increment. You might limit validity to /\w+/. In all cases, issue a warning when '-w' is used and the syntax of the argument is not OK. Johan -- Johan Vromans jv@mh.nl via internet backbones Multihouse Automatisering bv uucp: ..!{uunet,hp4nl}!mh.nl!jv Doesburgweg 7, 2803 PL Gouda, The Netherlands phone/fax: +31 1820 62911/62500 ------------------------ "Arms are made for hugging" -------------------------