#!/usr/bin/perl
#
srand;
%constants = qw(
   gravitational_constant(G) 6.67e-8
   speed_of_light(c) 3.00e10
   plank's_constant(h) 6.63e-27
   hbar 1.05e-27
   boltsmann's_constant(k) 1.38e-16
   stefan_boltsmann_constant(sigma) 5.67e-5
   radiation_constant(a) 7.57e-15
   protan_mass(mp) 1.67e-24
   neutron_mass(mn) 1.67e-24
   electron_mass(me) 9.11e-28
   hydrogen_mass(mH) 1.67e-24
   electron_change(e) 4.80e-10
   electron_volt(eV) 1.602e-12
   avocado's_number 6.02e23
   gas_constant(R) 8.31e7
   bohr_radius(a0) 5.29e-9
   solar_mass(Msun) 1.99e33
   solar_luminosity(Lsun) 3.83e33
   solar_radius(Rsun) 6.96e10
   solar_temperature(Tsun) 5770
   earth_mass(Mearth) 5.97e27
   earth_radius(Rearth) 6.38e8
   light_year(ly) 9.46e17
   parsec(pc) 3.09e18
   astronomical_unit(AU) 1.50e13
);

#=======================================================================#
#  how many questions do they want?                                     #
#=======================================================================#

print "How many questions do you want? ";
$num_questions = <STDIN>;

#=======================================================================#
#  print the question                                                   #
#=======================================================================#

for($i = 1; $i <= $num_questions; ++$i){
   @list = keys(%constants);

   $entry = $list[rand (@list)];
   $answer = $constants{$entry};

   print "What is $entry?\n";
   chomp($guess = <STDIN>);

   #=======================================================================#
   #  check to see if answer is correct                                    #
   #=======================================================================#

   while($guess ne $answer){
      print "*** Wrong, Try Again. ***\n";
      print "What is $entry?\n";
      chomp($guess = <STDIN>);
   }

   print "*** Correct ***\n";
}
