Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: how to loop

by rsiedl (Friar)
on Feb 21, 2007 at 02:20 UTC ( [id://601249]=note: print w/replies, xml ) Need Help??


in reply to Re: how to loop
in thread how to loop

thanks. i guess this'll work:
while (1) { # Get a random background from the array my $new = $backs[int(rand(@backs))]; # Set the background to something new system($command . ' --type=string -s '. $gconf_item . ' \'' . $new . + '\''); last if ($mode ne "running"); sleep($interval*60); } # end-while

Replies are listed 'Best First'.
Re^3: how to loop
by cbrandtbuffalo (Deacon) on Feb 21, 2007 at 15:00 UTC
    From a maintenance perspective, I like the previous example a bit more because you can understand the exit condition by reading the while line. Even a non-coder could understand it: while ($mode eq 'running'); keep going while the mode equals 'running'.

    In your example, I have to search through the entire block and find the 'last if' line to figure out how you break out of the loop.

    They are basically equal, but I find the first example easier to read and understand.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2026-02-16 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.