Pages: [1]   Go Down

Author Topic: Quick perl hack for question pool drilling  (Read 1989 times)

KF6IIU

  • Posts: 18
    • HomeURL
Quick perl hack for question pool drilling
« on: March 17, 2003, 03:29:48 PM »

#!/usr/bin/perl

# This is a quick hack I use to print out a question
# from the question pool, and then wait for a response,
# then print the answer. Works with the question
# pool text files downloaded from ARRL.org. The ones I # miss, I make a note and go back to the ARRL handbook # to study up on that topic.

#require "StandardFile.pl";

$debug++;
$|=1;
# Set $topdir and $infil to wherever your copy
# of the question pool is...
#$topdir='c:\\WINDOWS\\Profiles\\w\\My Documents';
#$infile = "$topdir\\genpool.txt";
$topdir='/home/wsanders/Kf6iiu';
$infile = "$topdir/2002_Extra_Pool3.txt";
$n=-1;
open(INFILE,"<$infile") || die "cant open $infile\n";

while (<INFILE>) {

if ( / \(A\)/ ) { $n++ ; $answer{$n} = "A" ; next  }
if ( / \(B\)/ ) { $n++ ; $answer{$n} = "B" ; next  }
if ( / \(C\)/ ) { $n++ ; $answer{$n} = "C" ; next  }
if ( / \(D\)/ ) { $n++ ; $answer{$n} = "D" ; next  }

if ($n > -1 ) { $text{$n} = $text{$n}.$_;}

}

close INFILE;
print "\nread $n questions\n\n";

for ($i=0; $i <= $n ; $i++ ) { $ord{rand()}=$i }

foreach $j (sort keys %ord) {
        $q=$ord{$j};
        print $text{$q};
        while ( ! <STDIN> ) { print "Never gets here\n" }
        print "ANSWER IS $answer{$q}\n\n\n";
        }

print "\n\nDone"; sleep 10;
Logged
Pages: [1]   Go Up