Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-28 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found