haukex:

Hmmm ... I just played around with it using Devel::Peek to see what the values in the sequence are:

#!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.


In reply to Re^4: curious behavior: why does it do this? by roboticus
in thread curious behavior: why does it do this? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.