in reply to Re: Modulus zero error
in thread Modulus zero error

Yeah... I didn't really understand the line number - it said "line 25, <> line 3." (line 25 is the if statement) And when I truncate line 25, the error stops happening - i don't see how that line can affect the while part, since it's not changing anything..

Replies are listed 'Best First'.
Re^3: Modulus zero error
by sasikumar (Monk) on Dec 24, 2004 at 05:46 UTC
    Cool

    The answer is perl has built a hash table in your while statement but when it comes to if it see's $p.. which is a new variable accordint to perl.. So there comes the problem. This is why it states the error in a wrong place


    Note:
    Use Strict and warnings

    Update:
    OOps sorry i mis understood the problem. Ok The problem lies in this line
    if (($n < $p[$i]) && ($x > $p[-1])) # error here

    just remove the previous code and use this u will not see the warning.
    if (($n < $p[$i]))

    This is becasue the lt operator should work by finding the modulus and then determine the solution.(I am not sure with that but for this error i hope this could be the reason. i will update on you again after 15 minutes

    Sorry i was not able to find it out....

    Thanks
    Sasi Kumar
      Eek... I don't understand, got lost at "built a hash table in your while statement" :( (I'm new to perl and programming in general, don't really know all that much about it yet...)

      I just want to know why
      if (($n < $p[$i]) & ($x > 2)) gives me errors and
      if (($n < $p[$i]) & ($x)) doesn't

      I tried use strict, warnings, didn't tell me anything different

        Can I ask... are you trying to do a Logical short-circuit AND (&&) in your if statement (to make sure both components are "true") or are you intentionaly performing a binary AND (&) on the data?

      I didn't understand that at all; could you try to say it again?