#!/usr/bin/env perl # -*- mode: Perl;-*- # Version 4.20.8 # See the file COPYING in the main distribution directory for copyright notice. unshift (@INC, '/home/ff/cs61b/grading-software/share/lib'); require "GradingBase.pl"; CmndLine ("", 1, 2); require "GradingCommon.pl"; $lastNamePatn = $ARGV[0]; @names = (); if ($#ARGV == 1) { $firstNamePatn = $ARGV[1]; } elsif (-f "$REGISTER_DIR/$lastNamePatn") { push (@names, $lastNamePatn); } else { $firstNamePatn = ".*"; } if (not @names) { opendir (REGISTRY, $REGISTER_DIR) || Fatal ("No registration directory."); while (defined ($login = readdir (REGISTRY))) { next if (! -f "$REGISTER_DIR/$login"); next if (ReaderExists ($login)); open (ENTRY, "$REGISTER_DIR/$login") || Warn ("Could not read registration for $login: $!"); $last = $first = 0; while () { chomp; LINE: { /^Last name:\s*($lastNamePatn)\s*$/oi && do { $last = 1; last LINE; }; /^First name\(s\):\s*($firstNamePatn)\s*$/oi && do { $first = $1; last LINE; }; }; } close (ENTRY); if ($last && $first) { push (@names, $login); } } closedir (REGISTRY); } if ($#names == -1) { if ($#ARGV == 1) { print STDERR ("No matches for last name matching $lastNamePatn, " . "first names matching $firstNamePatn.\n"); } else { print STDERR "No matches for $lastNamePatn as last-name pattern or login.\n"; } exit 1; } print STDOUT ("Found " . ($#names + 1) . " match" . (($#names==0) ? ".\n" : "es.\n")); foreach $login (@names) { if (open (ENTRY, "$REGISTER_DIR/$login")) { print STDOUT "\n$login:\n"; foreach $line () { print STDOUT " $line"; } close (ENTRY); } else { Warn ("Could not read registration for $login: $!"); } } exit 0;