Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Random lines from a file for a quiz

by benn (Priest)
on Aug 10, 2003 at 01:44 UTC ( #282530=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Random lines from a file for a quiz
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://282530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-29 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls