Help for this page

Select Code to Download


  1. or download this
    my @lines = <QUESTIONS>; # The entire file in an array
    my @questions = (); # A new array for questions
    ...
    }
    # and then to get the last one
    push(@questions,$tmp) if $tmp;
    
  2. or download this
    my @rand_questions = ();
    foreach (0 .. $num_questions_per_test) {
         my $rand = int(rand(scalar(@questions) - 1);
         push(@rand_questions,$questions[$rand]);
    }