i'm trying to write a script that will generate 95 random numbers. basically i have a file that has 95 lines in it and i want it to randomly mix them up. i tried writing the below code, but it does not exit and keeps crashing.
if there is another way to do this please let me know,
thanks so much for your time!
~ Nate_Bro
Code:
open(FILE, "Format.txt");
@Coded = <FILE>;
close(FILE);
@MyUsed;
$NumberCheck;
for($i=0;$i<=$#Regulare;$i++){
# $Regulare[$i] =~ s/\n//g;
$lower=0;
$upper=$#Coded;
$random = int(rand( $upper-$lower+1 ) ) + $lower;
while (! $NumberCheck){
CheckRandom($random);
}
@MyUsed = (@MyUsed, "$random");
}
open(FILE, "> DoneCode.txt");
print FILE "@MyUsed";
close(FILE);
sub CheckRandom(){
my ($rand) = @_;
for($n=0;$n<=$#MyUsed;$n++){
$myNumber = $MyUsed[$n];
if ($myNumber == $rand){
$random = int(rand( $upper-$lower+1 ) ) + $lower;
} else {
$NumberCheck = 1;
}
}
}
if there is another way to do this please let me know,
thanks so much for your time!
~ Nate_Bro