Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Random lines from a file for a quiz

by benn (Vicar)
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://282530]
[LanX]: machiato!
shmem fills a glas with sambuca, drops 3 beans of coffee into it, lights the stuff and hands it to erix
[Your Mother]: Liquore Strega. :P
[shmem]: s/beans of coffee/enterprise beans/ :-P
[erix]: Take your bottles -- you're all invited! :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-03-28 12:22 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (330 votes). Check out past polls.