#!/usr/local/bin/perl -w # # Change that path if your perl ain't in /usr/local/bin # # question.pl # # simple perl script to handle asking questions of the judges # # Copyright (C) 2000-2006 Ben Breech # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # Ben Breech 1/17/00 # use strict; my ($judge, $mailer, $quest, $prob, $team, $foo); # address of the person receiving submissions. Don't forget to put # a \ in front of the @ sign. Otherwise perl won't like it very much. $judge = "breech\@cis.udel.edu"; # mailer to use on this system. Put SUBJECT where the mailer expects # to see the subject heading (don't worry. SUBJECT will get replaced # later on) ADDR is where the mailer wants the address of the recepient. # here's some example mailers to use. # the following works on Solaris $mailer = "/bin/mailx -s SUBJECT ADDR"; # linux (redhat at least) # $mailer = "/bin/mail -s SUBJECT ADDR"; # digital UNIX # $mailer = "/usr/bin/mailx -s SUBJECT ADDR"; $prob = prob_num (); $team = team_num (); question (); print "\n\n"; print "This is what you've given me: \n"; print "Team: $team\n"; print "Problem: $prob\n"; print "Your question is: \n\n$quest\n"; print "\n"; print "Last chance to back out.\n"; print "If you hit return here, I'll assume a `yes'\n"; print "Should I submit the query (y/n) --> "; $foo = ; chomp $foo; if ($foo eq "" || $foo =~ /y.*/i) { my $sub = "UD00 query $prob team $team "; my $line; $mailer =~ s/SUBJECT/\"$sub\"/; $mailer =~ s/ADDR/$judge/; open (MAIL, "|" . $mailer) or die "Can't open mailer program. Bye.\n"; print MAIL $quest; close (MAIL); print "Question submitted.\n"; } else { print "Question NOT SUBMITTED.\n"; } exit (0); # # usage # # prints a (hopefully useful) usage message. # sub usage { print "Usage: $0 [filename]\n\n"; print " where filename is the name of the file to submit.\n"; print " if no filename is provided, you'll be asked.\n"; } # # team_num # # gets the team number, and does a quick check or two on it. # sub team_num { my $t; print "Team number: "; $t = ; chomp $t; if ($t !~ /^[0-9]+$/) { print "$t: Invalid team number. Bye\n"; exit (1); } return $t; } # # prob_num # # gets the problem number and does a quick check or two on it. sub prob_num { my $p; print "Problem number: "; $p = ; chomp $p; if ($p !~ /^[0-9]+$/) { print "$p: Invalid problem number. Bye\n"; exit (1); } return $p; } # # question # # returns the user's question # sub question { my $line; print "Please enter your question below. Terminate your question " . " with a ctrl-D\n"; $quest = ""; while (defined ($line = )) { $quest = $quest . $line; } }