in reply to Random lines from a file for a quiz
Tie::File (which is like your filehandle->array idea) could come in handy here, especially if you've got *lots* of questions :)
Cheers, Ben.use Tie::File; use List::Util qw(shuffle); tie @questions, 'Tie::File',"questions.txt" or die $!; my @qnums = shuffle(0..$#questions); foreach (@qnums) { print $questions[$_]; # get answer & write to file etc. }
|
---|
In Section
Seekers of Perl Wisdom