#!/usr/bin/perl
# A script to clean up the local mail spool
# to include only mail from Cron...
# Read the spool into an array
open (EGS21, "cat egs21Spool |");
while (<EGS21>) {push(@egs21,$_);}
close (EGS21);
# Open an output pipe...
open (PROCESSED, "| cat >../HTMLs/localSpool.html");
# Keep processing the array @egs21 until it is emptied
print PROCESSED "<html><body bgcolor=\"#46aod2\"><h1>/var/spool/mail/egs21<br></h1><code>\n";
do {
print PROCESSED "<hr>\n";
print PROCESSED &findAndPrint;
} until (!@egs21);
print PROCESSED "<hr>\n</code></body></html>\n";
# --- SUBROUTINES ---
# Search for things...
sub findAndPrint {
local($out, $line);
# Find the `From: webmaster-stu...' line
while (($line=shift(@egs21))&&!($line=~/From: web/)) {}
# Save it...
$out.=$line."<br>\n";
# Fint the `Date: ...' line
while (($line=shift(@egs21))&&!($line=~/Date:/)) {}
# Save it...
$out.=$line."<p>\n";
# Add the next blankLine...
$out.=shift(@egs21);
# And save the message, which terminates with
# the next message or empty array...
while (
($line=shift(@egs21))
&&!
(($line=~/From egs21/)||(!@egs21))
# next msg^^^^^^^^^^ ^^^^^^^ empty array
) {$out.=$line."<br>\n";}
return $out;
}