#!/usr/bin/perl -w use strict; srand(); my @array1=(); my $Max_Questions = 30; #Will vary upon how many questions #the person wants to answer my $ref = random(\@array1,$Max_Questions); sub random{ my $array = shift; my $Max = shift; my $lines = 100; #There is a function that gets the #number of lines in the actual data #file, but there will be at least 100. my $num = int(rand($lines)+1); push(@$array,$num); my $length = @$array; my $backcheck = 0; while($length != $Max){ my $numcheck = $num; $num = int(rand($lines)+1); if(($numcheck != $num) && ($num != @$array[$backcheck])){ push(@$array,$num); $length += 1; $backcheck = $length-2; } } my @sorted = sort {$a<=>$b} @$array; print"Element\t\tUnsorted\tSorted\n"; print"-------\t\t--------\t------\n"; for(my $z = 0;$z<$Max;$z++){ print" $z"; print"\t\t @$array[$z]\t\t"; print" $sorted[$z]\n"; } }