This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #133695) "0".."-1" should act like 0..-1
authorHauke D <haukex@zero-g.net>
Fri, 30 Nov 2018 12:06:07 +0000 (13:06 +0100)
committerTony Cook <tony@develop-help.com>
Thu, 8 Aug 2019 00:40:05 +0000 (10:40 +1000)
commitd1bc97feec1ac3a922c2ff2e27c9f517722cc565
tree94e4420337336d66c898279bdaa2ce17a9c01d93
parent9bceefdb82ae645c3112967e6c233ed719b425f9
(perl #133695) "0".."-1" should act like 0..-1

Previously, *any* string beginning with 0, including the string "0"
itself, would be subject to the magic string auto-increment, instead of
being treated like a number. This meant that "-2".."-1" was the same as
-2..-1 and "1".."-1" was the same as 1..-1, but "0".."-1" was the same
as "0".."99".

This patch fixes that inconsistency, while still allowing ranges like
"01".."31" to produce the strings "01", "02", ... "31", which is what
the "begins with 0" exception was intended for.

This patch also expands the documentation in perlop and states the rules
for the range operator in list context with both operands being strings
more explicitly.

See also #18165 and #18114.
pod/perlop.pod
pp_ctl.c
t/op/range.t