#!/usr/athena/bin/perl # Email Sorting Script - written by twm@mit.edu # # Overview - Requires: generate_brothers # "headers" is a file where each line is in the format: # ||...| # Username is the username of a brother, and a header file # entitled .html must exist. # Effects - Searches through all the files in "directory" # for all the occurances of search1, search2,... search-n, # takes the subject headings from each file in which these # search strings occur, converts these to hmtl links, and appends them # to the contents of .html storing the results in # a file called -pl.html The search is done using egrep # and the username is also used in the search. $ARGC = @ARGV; $headers = $ARGV[0]; $directory = $ARGV[1]; open(HEADERS, $headers); @brothers = ; $brothers = @brothers; $counter = 0; while ($counter < $brothers) { $brother = $brothers[$counter]; $cut = index($brother, " "); $name = substr($brother, 0, $cut); $search = substr($brother, $cut+1); chop($search); $cmnd = join("", "egrep -l '", $name, "|", $search, "' ", $directory, "/* > /tmp/stuff"); print "\n\n", $name, "\n", $cmnd; system $cmnd; open(STUFF, "/tmp/stuff"); @refs = ; $refs = @refs; $count2 = 0; system join("", "cp ", $name, ".html ", $name, "-pl.html"); open (BRO, join("", ">>", $name, "-pl.html")); write(BRO); print(BRO join("", "\n\n
\n\n

Archived email to plp and jolly-laddies which reference ", $name, "

\n")); print(BRO "\n
    \n"); while ($count2 < $refs) { $f = $refs[$count2]; chop($f); $cmnd1 = join("", "egrep '^Subject' ", $f," |"); open(PIPER, $cmnd1); @subject = ; $subject = pop(@subject); $cmnd2 = join("", "egrep '^From' ", $f," |"); open(PIPER, $cmnd2); @author = ; $author = pop(@author); $cmnd3 = join("", "egrep '^Date' ", $f," |"); open(PIPER, $cmnd3); @thedate = ; $thedate = pop(@thedate); $link = join("", "
  • \n", "Mail ", $subject, "
    \n", $author, "
    \n", $thedate, "\n"); print(BRO $link); $count2 = $count2 + 1; }; close(PIPER); print(BRO "
\n\n"); print(BRO "
\nMaintained by twm@mit.edu\n"); close(BRO); $counter = $counter + 1; };