#! /usr/bin/perl #First parameter is name of results file to read through and second parameter is the string to #look for. It then finds a number somewhere after that string and on the same line. That number #is considered the grade. integers and floating point are OK. Second parameter defaults to #"Final Score is" #output file is in Data directory, scores-ARGV.lst $filename = shift @ARGV; ($dir) = $filename =~ m:(\w+)[_-]results:; $home="/u/cs/class/cs131/cs131xx"; $prefix= (shift @ARGV or "Final Score is"); $prefix =~ s:\s*$::; unless ($dir) { print "Syntax is make-scores-list filename [prefix] eg: make-scores-list hw2-results OR make-scores-list hw2_results OR make-scores-list hw2-results \"Total Score is\" Script looks for number following prefix which defaults to Final Score is\n"; exit; } @files=`grep -i \"$prefix\" $home/*/$filename`; foreach $file (@files) { # next if ($file =~ m:$home/[A-Z]:o); next unless $file=~ m:$home/([a-z]\w+)/.*$prefix.*?(\d+(\.\d+)?):o; #? is minimum matching if ($1 && $2 ne "") { push @scores, "$1 $2\n"; } else { print "No grade found for $file"; } } open (OUT, ">$home/Data/scores-$dir.lst") or die "Can't create $home/Data/scores-$dir.lst: $!\n"; print OUT @scores; close OUT;