$howmany = 1000; # this is the variable to hold the x number # assuming that you can get the number of ss#'s in some variable $numberOfss for (0..$howmany) { my $ra = int(rand($numberOfss)); print $ra,"\n"; # do whatever you want with it here.. }