Well, it does seem a little odd to me to have
echo -e "1\n2\n3\n4" | perl -lne 'print if 2..2'
return the same as
perl -le 'print 2..2'
while
echo -e "1\n2\n3\n4" | perl -lne 'print if 2...2'
returns something very different from
perl -le 'print 2...2'
I understand why it does, but it would seem preferable to either disallow ... in list context, or make it behave "the same" in list and scalar contexts. (So the list 2...2 would be 2,3,...,INTMAX, and the list a()...b() would be the same as a()..b() unless a()==b(), in which case it would be a(),...,INTMAX.)

Although, come to think of it, I think what would really make sense is if someone wrote a source filter than numbers all of the operators, with .. in slot 2 and ... in slot 3, so that you can use a sequence of periods of the appropriate length to choose any operator in Perl. Perl likes gathering up different programming paradigms, right? (Functional, OO, logical, ...) So this would make it easier to implement the genetic algorithm style, where you start off with something simple like

$x = $x ....... $y ...... $z ...... $x; $y = $x ...... $y ........... $z; $z = $x .... $y ........ $z;
and then you can easily mutate and interbreed code merely by changing the number of periods. Repeat until you get the answer desired. Some of my debugging sessions already closely resemble this.

In reply to Re: Re: Perl treats '...' the same as '..'. Why? by sfink
in thread Perl treats '...' the same as '..'. Why? by samtregar

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.