[system] / trunk / webwork / system / scripts / update_classlist_from_8_to_9_fields.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/scripts/update_classlist_from_8_to_9_fields.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (download) (as text) (annotate)
Mon Jun 25 18:20:05 2001 UTC (18 years, 5 months ago) by sam
File size: 1778 byte(s)
Removed unneeded scripts (as per discussion with gage, apizer). Added
BEGIN-block method for library inclusion to command-line scripts.

    1 #!/usr/local/bin/webwork-perl
    2 
    3 use sigtrap;
    4 
    5 BEGIN {
    6   my $useLibDir = '.';
    7   if    ($0 =~ m|^(/.*)/|)  { $useLibDir = $1; }
    8   elsif ($0 =~ m|^(\..*)/|) { $useLibDir = $1; }
    9   elsif ($0 =~ m|^(.+)/|)   { $useLibDir = "./$1"; }
   10   unshift @INC, $useLibDir;
   11 }
   12 
   13 use webworkInit; # WeBWorKInitLine
   14 use Global;
   15 
   16 BEGIN {
   17 $SIG{__WARN__}= sub {};
   18 }
   19 
   20 
   21 require 5.000;
   22 
   23 
   24 require "$Global::scriptDirectory$Global::FILE_pl";
   25 
   26 if (@ARGV != 2) {
   27   print "\nSyntax is update_classlist_from_8_to_9_fields.pl in_file out_file\n";
   28   print "      (e.g. update_classlist_from_8_to_9_fields.pl mth101.lst mth101.lst)\n\n";
   29   exit(0);
   30 }
   31 
   32 my ($infile, $outfile) = @ARGV;
   33 my $length;
   34 
   35 open (INFILE, "$infile") || die "can't open $infile: $!\n";
   36 my @classList = <INFILE>;
   37 close(INFILE);
   38 
   39 my $outstring = '';
   40 my $line;
   41 
   42 foreach $line (@classList) {
   43     unless ($line =~ /\S/)  {next;}
   44     chomp $line;
   45     @classListRecord=&getRecord($line);
   46 
   47     $length = @classListRecord;
   48 
   49     unless ($length == 8) {
   50       my $string = join(',',@classListRecord);
   51       print "\n\n        The record \n
   52       $string\n
   53       in the file $infile contains $length items.\n
   54       All records must contain 8 items in order to run the update script.\n\n";
   55       exit;
   56   }
   57     my ($studentID, $lastName, $firstName, $status, $comment, $section, $email_address, $login_name)
   58        = @classListRecord;
   59   my $recitation = '';
   60     my @classArray=($studentID, $lastName, $firstName, $status, $comment,  $section, $recitation, $email_address, $login_name);
   61 
   62   ## and print that sucker!
   63   $line = join("$Global::delim", @classArray);
   64     $outstring .= "${line}\n";
   65 }
   66 
   67 open (OUTFILE, ">$outfile") || die "can't open $outfile: $!\n";
   68 print OUTFILE $outstring;
   69 close(OUTFILE);
   70 
   71   ## arrange the columns nicely
   72 
   73 &columnPrint("$outfile","$outfile");
   74 
   75 
   76 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9