#!env perl
use strict;
use warnings;
use Devel::Peek;
use Data::Dump 'pp';
use v5.20;
say qq{"8" .. "C" generates strings "8" .. "9"};
dump_seq("8" .. "C");
say qq{"8" .. "9" generates integers 8 .. 9};
dump_seq("8" .. "9");
say qq{"-1" .. "2" generates integers -1 .. 2};
dump_seq("-1" .. "2");
say qq{"B" .. "C" generates strings "B" .. "C"};
dump_seq("B" .. "C");
say qq{"9" .. "7" generates nothing};
dump_seq("9" .. "7");
say qq{"C" to "A" generates strings "C" .. "Z"};
dump_seq("C" .. "A");
sub dump_seq { Dump($_) for @_; print "---\n\n"; }
Running it gives (edited for brevity):
$ perl pm_1226451.pm
"8" .. "C" generates strings "8" .. "9"
SV = PV(0x600004240) at 0x600003680
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x600069f20 "8"\0
CUR = 1
LEN = 10
SV = PV(0x600004260) at 0x600003758
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x600172e00 "9"\0
CUR = 1
LEN = 10
---
"8" .. "9" generates integers 8 .. 9
SV = IV(0x600003670) at 0x600003680
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = 8
SV = IV(0x600003748) at 0x600003758
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = 9
---
"-1" .. "2" generates integers -1 .. 2
SV = IV(0x600003670) at 0x600003680
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = -1
SV = IV(0x600003748) at 0x600003758
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = 0
SV = IV(0x600003760) at 0x600003770
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = 1
SV = IV(0x600003898) at 0x6000038a8
REFCNT = 2
FLAGS = (IOK,pIOK)
IV = 2
---
"B" .. "C" generates strings "B" .. "C"
SV = PV(0x600004240) at 0x600003680
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x6001b5be0 "B"\0
CUR = 1
LEN = 10
SV = PV(0x600004260) at 0x600003758
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x600069f20 "C"\0
CUR = 1
LEN = 10
---
"9" .. "7" generates nothing
---
"C" to "A" generates strings "C" .. "Z"
SV = PV(0x600004240) at 0x600003680
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x6001b5be0 "C"\0
CUR = 1
LEN = 10
SV = PV(0x600004260) at 0x600003758
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x600069f20 "D"\0
CUR = 1
LEN = 10
<<< SNIP SNIP SNIP >>>
SV = PV(0x6001a99f0) at 0x6001a4160
REFCNT = 2
FLAGS = (POK,pPOK)
PV = 0x600196010 "Z"\0
CUR = 1
LEN = 10
---
It appears that when both values appear to be integers, it terminates the loop before generating any values if the second value is less than the first. For strings, it appears to just keep on going, terminating when it hits "the last letter". I wonder how it interacts with the locale for non-ASCII/English character sets. (Not motivated, however, to do the experiments myself, nor knowledgeable enough about Unicode and non-English character sets to be sure I could do the experiments well had I wanted to.)
...roboticus
When your only tool is a hammer, all problems look like your thumb. |