in reply to Boolean operators and list assignments

I'm actually not sure this is a problem with precedence or with list assignment. Note that the list assignment is in scalar context in both code blocks. The first is in the scalar context of &&; the second is in the scalar context of a while condition.

However, your two loops have different ending conditions; the first ends when $siteslisted >= $sitesperpage, while the second ends when $siteslisted < $sitesperpage. That may just be an error in retyping the code here, though.

Based on the code you posted, it's hard to say what the problem is...

Replies are listed 'Best First'.
Re: Re: Boolean operators and list assignments
by flymolo (Acolyte) on Dec 20, 2000 at 23:35 UTC
    Sorry that was a typing problem.
    it should be if ($siteslisted >= $sitesperpage) {last;}
    I am really confused, because I'd expect
    that a expression that can be used at a boolean on it's own
    should be usable with a boolean operator.
    "Sometimes it's hard to tell the dancer from the dance."-Corwin in CoC

      So are we (confused). You should probably do that standard work that you should always do when you run into a problem:

      Take the code that produces the problem and reduce it to a minimal example that reproduces the problem. You will likely discover the source of the problem when doing this. If you don't find the solution, then post exactly the very small script that reproduces the problem along with the exact input, output (including error messages), and what about the output you didn't like.

              - tye (but my friends call me "Tye")
      Okay, that clears up that little issue.

      I tried both of your code structures, and they both worked fine, stopping after $sitesperpage fetches from the database. I wonder if there is a bug in the actual code that isn't reflected in the posted code. Perhaps a mispelled variable name or something like that? Are you using -w and use strict?

        O well. Maybe I fixed my error in typing it. I no longer have the original code. But that loop took down apache. (Each iteration of the loop I was pushing
        some results to a list.) Apache's logs show it died due to malloc failing. I'm using both -w and use strict, so that's not the problem.

        "Sometimes it's hard to tell the dancer from the dance."-Corwin in CoC