in reply to how to loop

... (insert thoughtful face here) ... is it just me, or does $mode never change value inside the loop in any of the snippets posted so far?

Replies are listed 'Best First'.
Re^2: how to loop
by rsiedl (Friar) on Feb 21, 2007 at 05:27 UTC
    you're right. $mode never changes value during the running of the script. it's just set manually before running.
      Um... so if you edit the script so that $mode is set to something other than "running", the loop will execute just once, and the script exits; but if you edit the script so that $mode is set to "running", the script loops indefinitely until you kill it (^C or whatever). And that's the intended design?

      I would have expected that either (a) the value assigned to $mode would depend on @ARGV (or %ENV, or some other external input), or (b) there would be something inside the loop that could change the value of $mode, or else (c) each time you edit the script to change its behavior, rather than editing a variable assignment, you would just edit the loop condition -- e.g. do {...} while(0); vs. do {...} while(1);, or something to that effect. (Note that the former "do" block will execute exactly once, whereas the block in while(0){...} never executes.)

      As it is, I tend to share muba's puzzlement.

      (updated to fix spelling)

        yep, that was the intended design. the scripts purpose is to randomly select a wallpaper and set it in gnome2. i can then add it to my startup scripts, and it'll change the wallpaper, either once at login, or continuously while i am logged in, depending upon what i've set $mode to.

        i've modified it a bit more though, so maybe this makes more sense...