http://www.perlmonks.org?node_id=282530


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 :)
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. }
Cheers, Ben.