#! /usr/bin/perl
#Syntax is non-graded file results
#prints a list of accounts that have a submission file but not a results file
$home="/u/cs/class/cs131/cs131xx";
$file=shift @ARGV;
$results=shift @ARGV;
unless ($file && $results) {
  print "syntax is non-graded submission_filename results_filename\ne.g.   non-graded pr1.ss Project1-results\n";
  exit;
}

@hws=`ls $home/*/$file`;
map { m:$home/(\w+)/.*:o; $result.="$1 ";} `ls $home/*/$results`;
map { s:$home/(\w+)/.*:$1:so;} @hws;
shift @hws while ($hws[0]=~ m:[A-Z]:);

foreach $seas (@hws) {$nons.="$seas " if ($result !~ m:\b$seas\b:);}

if ($nons) {print "The following have submitted but not been graded:\n $nons\n";}
else  {print "All new $file submissions have results file\n";}

open (GL, "$home/Glogin") or exit;
while ($line=<GL>) {
  next unless ($line =~ m:\brename\b:);
  $line=~ m:alias \S+ \S+/rename (\S+ \S+):;
  if ($1) {
    close GL;
    system "$home/Scripts/rename $1";	#this exits non-graded script
  }
}
close GL;

