-2

I just wanna ask that if there is some kind of kind of program in which i insert PDF file with full of questions and that program select randomly and give it to me like a exam?!

For example: i am pilot and i got question bank (all mcqs) in PDF file, Now i should insert that file in the desired program and it randomly gives me questions! I hope u guys understand, I know my english and way of explainning is poor :(

1

2 Answers 2

1

If you're willing to paste it into a .txt, this snippet should do the trick for you:

#!/usr/bin/perl
use warnings;
use strict;

my @questions;
while (<>) { push(@questions,$_) }
print $questions[rand @questions];

Paste that into a new perl script, run it through your perl interpreter of choice with the name of a text file as arguement in this format:

Does a plane need wings?
Why do planes without wings fly so poorly?
What's the drag coefficient of a streamlined halfbody?
What happens to a Sonex travelling at 0.75C at 1000m altitude?
What happens to the planet earth in above scenario?

...etcetera.

2
  • Are you going to leave us hanging? What are the answers to those questions?
    – fixer1234
    Apr 12, 2015 at 22:54
  • 1. No 2. Insufficient thrust 3. 0.09 4. Elementary particles replace the aircraft 5. And parts of the atmosphere
    – Jarmund
    Apr 12, 2015 at 22:58
0

You may try pdftotext tool in the following way:

pdftotext list_of_questions.pdf - | grep -i question | shuf | head -n1

It'll print the random question (line which contain 'question' word) onto the screen from the given PDF file.

This will give you some initial idea, so you can extend based on your needs.

Not the answer you're looking for? Browse other questions tagged .