in reply to Random number in while loop
use strict; use warnings; [download]
This would have given you this type of warning message:
Argument isn't numeric in numeric eq (==) [download]
which (might) have led you to using the string operator eq instead of ==.