Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

When did Perl get it's range operator? Has it been there since 1987? Or is it a Perl 5 thing?

  • Comment on Perl history: when did Perl get a range operator?

Replies are listed 'Best First'.
Re: Perl history: when did Perl get a range operator?
by kcott (Archbishop) on Dec 09, 2015 at 23:30 UTC

    Looking in my Camel book (1st edition), I see the '..' range operator. The fact that it's really two distinct operators depending on context is mentioned. The wording (regarding context) isn't too different from what's in the current documentation: "perlop: Range Operators". I see no reference to the '...' range (flip-flop) operator in that book.

    In perlhist, I see:

    "Perl 4 introduced the first Camel book. Really. We mostly just switched version numbers so the book could refer to 4.000."

    So, that puts the list context '..' at least at Perl3. AM's response indicates (from O_FLIP) that the scalar flip-flop version was around at Perl1.

    Looking in my Camel book (2nd edition), I see the '...' range (flip-flop) operator is now mentioned. So, it looks like that didn't appear until Perl5.

    — Ken

Re: Perl history: when did Perl get a range operator?
by Anonymous Monk on Dec 09, 2015 at 20:13 UTC
    So it seems it was there in Perl 1.000.
    /* for "cond .. cond" we set up for the initial check */ if (arg->arg_type == O_FLIP) context |= 4;
    But I recall the ... (three dots) operator was added much later.
Re: Perl history: when did Perl get a range operator?
by james28909 (Deacon) on Dec 09, 2015 at 20:17 UTC

    I took a look around, this looks like a perl 4 reference guide of the sorts, which does include the range operator: '.. Enumeration, also input line range operator.'
    http://www.rexswain.com/perl4.html#operators

    I am having a hard time looking up any kind of references on perl version 1, 2, and 3.
      Wikipedia has a link to google archive of comp.sources.unix, which has what looks like the source of Perl 1 :)