http://www.perlmonks.org?node_id=204282


in reply to Re: How do you move within an array using foreach?
in thread How do you move within an array using foreach?

That looks like a useful thing to have around - I've never seen the /foo/ .. /bar/ notation before - I don't suppose you could explain it, or point me to a place that does?
  • Comment on Re: Re: How do you move within an array using foreach?

Replies are listed 'Best First'.
Re: Re: Re: How do you move within an array using foreach?
by Anonymous Monk on Oct 10, 2002 at 19:02 UTC
    It's called the "flip-flop" operator. See perlop
Re: ^3: How do you move within an array using foreach?
by flounder99 (Friar) on Oct 10, 2002 at 19:10 UTC
    Look here in perlop.

    In scalar context, ".." returns a boolean value. The operator is bistable, like a flip-flop, and emulates the line-range (comma) operator of sed, awk, and various editors. Each ".." operator maintains its own boolean state. It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, AFTER which the range operator becomes false again.

    --

    flounder

Re^3: How do you move within an array using foreach?
by JaWi (Hermit) on Oct 10, 2002 at 19:10 UTC
    As a matter of fact, I can (since about 15 minutes :-)! Summarizing from perlop:

    The two dots work like a sort of flip-flop: if returns true if the first operation (the /foo/ part) evaluates `true' and stays true until the second operation evaluates to `true' (the /bar/ part). After that it returns false again.

    Cheerio,

    -- JaWi

    "A chicken is an egg's way of producing more eggs."

Re: Re: Re: How do you move within an array using foreach?
by thelenm (Vicar) on Oct 10, 2002 at 19:04 UTC
    Look in the perlop documentation, under the "Range Operators" section. All the various uses of .. are explained there in detail.

    -- Mike

    --
    just,my${.02}