in reply to Modulus zero error

I don't think we can give a solid answer without knowing better what @p contains. If @p is empty or is a new variable ("use strict"), then the first time through the loop while ( $x % $p[$i] != 0 ) could report a "use of undefined in modulus" because $p[$i] is undefined.

-xdg

Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.