Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: How do you move within an array using foreach?

by jbeninger (Monk)
on Oct 10, 2002 at 18:51 UTC ( #204282=note: print w/ replies, xml ) Need Help??


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?
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: 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}

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://204282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2014-12-29 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (187 votes), past polls