in reply to Re^2: curious behavior: why does it do this?
in thread curious behavior: why does it do this?
I'm puzzled (in an idle sort of way) as to why print for "1" .. "-1"; doesn't output the numbers 1 through to 99.
That is indeed quite strange, and I can't make sense of it at the moment... seems like a bug to me.
$ perl -wMstrict -MData::Dump -e' dd "0".."-1" ' (0 .. 99) $ perl -wMstrict -MData::Dump -e' dd "1".."-1" ' () $ perl -wMstrict -MData::Dump -e' dd "01".."-1" ' ("01", "02", "03", "04", "05", "06", "07", "08", "09", 10 .. 99) $ perl -wMstrict -MData::Dump -e' dd "90".."-1" ' () $ perl -wMstrict -MData::Dump -e' dd "1".."xx" ' (1 .. 99) $ perl -wMstrict -MData::Dump -e' dd "11".."xx" ' (11 .. 99) $ perl -wMstrict -MData::Dump -e' dd "90".."xx" ' (90 .. 99) $ perl -wMstrict -MData::Dump -e' dd "-1".."xx" ' -1 $ perl -wMstrict -MData::Dump -e' dd "0".." -1 " ' (0 .. 9999) $ perl -wMstrict -MData::Dump -e' dd " 0 ".." -1 " ' () $ perl -wMstrict -MData::Dump -e' dd " 11 ".." -1 " ' () $ perl -wMstrict -MData::Dump -e' dd "0.0".."-1.0" ' "0.0" $ perl -wMstrict -MData::Dump -e' dd " 0.0 ".." -1.0 " ' () $ perl -wMstrict -MData::Dump -e' dd "0.0".." 1.0 " ' "0.0" $ perl -wMstrict -MData::Dump -e' dd " 0.0 ".."1.0" ' (0, 1)
Maybe there's some kind of heuristic going wrong... for example, maybe the intention is that if both sides looks_like_number, then treat them as numbers instead of strings - but several of the cases above don't work like that. I dunno at the moment, this may need some digging in the sources. (I ran a bisect earlier, and it seems that at least the "1".."-1" case has always returned the empty list.)
Update: Reported as Bug #133695
Update 2019-08-27: See this node, which documents the behavior, as well as the change in the behavior as of Perl v5.32.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: curious behavior: why does it do this?
by roboticus (Chancellor) on Nov 28, 2018 at 18:18 UTC | |
by syphilis (Archbishop) on Nov 29, 2018 at 03:47 UTC | |
by haukex (Archbishop) on Nov 30, 2018 at 14:09 UTC | |
|
Re^4: curious behavior: why does it do this?
by rsFalse (Chaplain) on Nov 29, 2018 at 00:10 UTC |