in reply to infinite loop does not stop
The reason for this is that $rand (and, therefore, $firstcontact and $secondcontact) are always 0 because nothing ever gets passed to your subroutine which means you are effectively writing: $rand = int( rand() );
To start, I suggest adding:
use strict; use warnings;
Also, take a look at perlsub to better understand how to pass values to subroutines and return what you want. While you are there, be sure to pay attention to the parts about scope since you typically want your variables in your subroutine to be isolated.
|
|---|