If that were the correct interpretation, then '2'..'1' should be the same as '2'..'9' but:

perl -de 0 DB<1> p join " ", '2'..'1' DB<2> p join " ", '2'..'9' 2 3 4 5 6 7 8 9 DB<3>
So it appears that perl 5.6.1 incorrectly doesn't realize that '0' comes before '1' when you write '1'..'0' but gets it correct for '1' through '8' since '9'..'8' and others give empty lists.

Note that 5.004_01 gets '1'..'0' correct but incorrectly thinks 'c'..'b' is the same 'c'..'z' (as does v5.6.0). So this is apparently a poorly-tested corner of the code.

...As well as being misleadingly documented. I'm confident that the original intent was that things like 'c'..'a' would return the empty list. So the code and the documentation both need to be patched to make this clear.

Update: Note that perl 4.036 realizes that '1'..'0' is the empty list but incorrectly thinks 'w'..'c' is the same as 'w'..'z'. So by no means a new bug. (:

        - tye (but my friends call me "Tye")

In reply to (tye)Re2: Range operator weirdness? by tye
in thread Range operator weirdness? by PrakashK

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.