Advertisement
GregLeblanc

Untitled

Mar 6th, 2024
872
0
301 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.80 KB | Source Code | 0 0
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4.  
  5. use CGI qw(:standard);
  6.  
  7. my $particle = param("particle");
  8. my $charge = param("charge");
  9. my $frequency = param("frequency");
  10. my $nmrtable_data = "/usr/local/lib/nmrtable_data";
  11. my $line;
  12.  
  13. # Constants
  14. my $M_zero      =   1876.5592;
  15.  
  16. sub calculate_frequency {
  17.     print p("In the sub");
  18.     open (file_handle, "<$nmrtable_data") or die qq(Unable to open "$nmrtable_data");
  19.     foreach (<file_handle>) {
  20.         if (($_ =~ /$particle/) and ($_ =~ /$charge/)) {
  21.             print p($_);
  22.         }
  23.     }
  24. }
  25.  
  26. print header, start_html(-title=>"EAL Energy Calculator",
  27.         author=>"leblanc\@ohio.edu");
  28. print '<STYLE type="text/css">';
  29. print ' H1.myclass {border-with: 1; border: solid; test-align: right;}';
  30. print '</STYLE>';
  31. print '<H1>EAL Energy Calculator</H1>';
  32.  
  33. if ($frequency eq "") {
  34.     print hr, start_form;
  35.     print p("Please select particle: ", popup_menu("particle",
  36.             ['PROTONS','DEUTERONS','HELIUM-3','ALPHAS',
  37.             'LITHIUM-6','LITHIUM-7','BORON-10','BORON-11',
  38.             'CARBON-12','CARBON-13','NITROGEN-14',
  39.             'NITROGEN-15','OXYGEN-16','ALUMINUM-27']));
  40.     print p("Please select charge state: ", popup_menu("charge",
  41.             ['+1','+2','+3','+4','+5','+6','+7','+8']));
  42.     print p("Please enter NMR Value (in MHz): ",textfield("frequency",""));
  43.     print p(submit("Calculate"), reset("Clear"));
  44.     print end_form, hr;
  45. } else {
  46.     print hr, start_form,p;
  47.     print "<TABLE>";
  48.     print "<TR><TH>Particle:<TD><big><b><font size=+1 color=#0000ff>$particle</font></b></big></TR>";
  49.     print "<TR><TH>Charge State:<TD><big><b><font size +1 color=#0000ff>$charge</font></b></big></TR>";
  50.     print "<TR><TH>Energy (MeV):<TD><b><font size=+1 color=#0000ff>$frequency</font> </b></TR></TABLE>";
  51.     calculate_frequency();
  52.     # print p("$nmrshow"),hr;
  53.     print p(defaults("Continue"));
  54.     print end_form;
  55.     $frequency = undef();
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement