mhearse has asked for the wisdom of the Perl Monks concerning the following question:

In reading Learning More Perl, I need the following code explained:
unless ($turn) { print "on course.\n"; return; }
How (and for what) is turn being evaluated? I can't find much on the until statement, except that it evaluates for non-truth.

janitored by ybiC: Retitle from "Until loop", add balanced <code> tags

Replies are listed 'Best First'.
Re: unless ($turn){...} evaluates $turn for what?
by valdez (Monsignor) on Sep 06, 2003 at 19:12 UTC

    unless ($turn) can be read as if (not($turn)). What's the problem with until?

    Ciao, Valerio

Re: unless ($turn){...} evaluates $turn for what?
by LordWeber (Monk) on Sep 06, 2003 at 20:31 UTC
    Re: unless ($turn){...} evaluates $turn for what?
    by bradcathey (Prior) on Sep 06, 2003 at 20:49 UTC
      Not so sure I understand the question. Having said that, the until is just another great way Perl allows a "conditional loop". Don't read too much into it. Set up some examples with do/hile/until or if/until and see how each works and decide what's best for any given situation. It's more fun than just doing if/else every time.
    Re: unless ($turn){...} evaluates $turn for what?
    by bradcathey (Prior) on Sep 06, 2003 at 21:03 UTC
      Just stumbled across this little thread on until in until loops. Check it out, especially the replies.
    Re: unless ($turn){...} evaluates $turn for what?
    by mhearse (Chaplain) on Sep 06, 2003 at 20:37 UTC
      Right, I meant unless in the title. It makes sense. $turn is being evaluated for truth.