Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: Looking for the first item in the chain

by Laurent_R (Canon)
on Aug 10, 2014 at 21:42 UTC ( #1096933=note: print w/replies, xml ) Need Help??


in reply to Re^4: Looking for the first item in the chain
in thread Looking for the first item in the chain

The $continue variable is just there to control the while loop. The idea is that you have to iterate on a data structure an unknown number of times. So long as you make a change, it means that further changes might be needed. But it you did not need to make any change, then you are guaranteed that you will not need to make any further changes. So you set $continue to true (1) before the loop, to make sure you enter the loop at least once. Then, you immediately set it to false (0). And, if you had to make any change, you set it to true (1), because you might have to iterate once more. But if you didn't need to make any change, then you are done, all the required changes have been done.

Another monk previously called the same variable "changes" in another answer to this thread, but $changes and $continue have essentially the same purpose.

  • Comment on Re^5: Looking for the first item in the chain

Replies are listed 'Best First'.
Re^6: Looking for the first item in the chain
by vagabonding electron (Curate) on Aug 16, 2014 at 14:48 UTC

    Sorry for late responce and thank you very much again!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-02-08 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?