On Sat, 12 Mar 2022 at 15:10, Glenn Golden <gdg@zplane.com> wrote: > > demerphq <demerphq@gmail.com> [2022-03-12 14:23:12 +0800]: > > On Sat, 12 Mar 2022, 05:19 William Lindley, <wlindley@wlindley.com> wrote: > > > > > In all this discussion, what happens when reading a file > > > > > > Any data that was read from a file would be a string unless you did > > something to tell perl otherwise. > > > > containing the > > > line: > > > > > > 01730 > > > > > > which is the postal code for my hometown. This "looks like" a number > > > > > > I don't believe it does actually. The leading 0 means that > > looks_like_number() should reject it. > > > > Could you expand a bit on what you meant above by "should reject"? > > I didn't understand if you meant it in the sense of "should be rejected > by looks_like_number() as implemented in the upcoming Perl release", or > if you meant more generally that rejection "should be the current _and_ > future behavior". > > I'm asking because my experience with looks_like_number() has been (for > many years, up to and including 5.34) based on the attached script and > set of test case strings, several of which have leading zeros. TTBOMR, > the leading-zeros cases in the first group have always been classified > as "a number" by Scalar::Util::looks_like_number(). I apologize, I wrote that on my phone when I didn't have my laptop handy and I didn't actually check Scalar::Util::looks_like_number() to verify what I said, hence the "I believe" and "should". Obviously I was wrong, my bad. I think I got muddled with a different function that is used to verify if 0+$val eq "$val", which is necessary for validating for round trip safe serialization. Sorry about that. And when I say reject i mean would return false, as opposed to accept where the return would be true. > I added a few more cases just now for a little better test coverage, > and all seem to still accord with my historical (and present) expectations > as a Certified Perl Moron. Am I making some mistake in the way that the > test script makes its determination? > > Are any of these test cases expected to change in the upcoming release? I am not aware of any plans to change that. If its accepted now then its hard to imagine that someone would change it. Cheers, Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next