in reply to curious behavior: why does it do this?
So nothing about invalid octal constants from perl. ... *Ouch*, on a whim, I tried inserting a 0 before the 10, thinking my list iteration _might_ stop at 8, I.e.:> tperl use Scalar::Util qw(looks_like_number); for my $i ("00".."10") { P "%s(%d) %s like a number", "$i", "$i", looks_like_number($i) ? "look +s":"does not look"; }' 00(0) looks like a number 01(1) looks like a number 02(2) looks like a number 03(3) looks like a number 04(4) looks like a number 05(5) looks like a number 06(6) looks like a number 07(7) looks like a number 08(8) looks like a number 09(9) looks like a number 10(10) looks like a number
I got an enumeration up through 999. Another unexpected result! Or is that really what others expected?for my $i ("00".."010") {...
Perhaps as a nod to sanity, using 010 (with no quotes) as an end-value did end at 8, but the entire sequence was numified (with the leading 0 missing):
0(0) looks like a number 1(1) looks like a number 2(2) looks like a number 3(3) looks like a number 4(4) looks like a number 5(5) looks like a number 6(6) looks like a number 7(7) looks like a number 8(8) looks like a number
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: curious behavior: why does it do this?
by haukex (Archbishop) on Dec 10, 2019 at 05:21 UTC |