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

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

Replies are listed 'Best First'.
Re^4: Modulus zero error
by Anonymous Monk on Dec 24, 2004 at 06:29 UTC
    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?

        Nope, that was just me being ignorant... I changed it to &&, but it still behaves the same way
Re^4: Modulus zero error
by ysth (Canon) on Dec 24, 2004 at 05:50 UTC
    I didn't understand that at all; could you try to say it again?