jstuart@math-cs.kent.edu (Jeff Stuart) (10/09/90)
Well, I've finally done it. I've written my first major program in
Perl. If I could I'ld like to ask for a couple of people to look at my
perl code and chop it to pieces. I feel that that way, I'll soon be up
to speed writing real perlese code. :-)
Please email and I'll summarize.
Code is listed below skip now.
:
#! /dist/perl/perl
eval "exec /dist/perl/perl -S $0 $*"
if $running_under_some_shell;
&init();
open (ERROR_LOG, '/busaf/uscinv/bin/error_log') || die "couldn't find error_log";
while (<ERROR_LOG>)
{
# See if this is a header line for error messages.
$check_line = 0;
$check_line = 1 if (grep(/^[Sun|Mon|Tue|Wed|Thu|Fri|Sat]/,($_)));
# Is there ANY better way to do the above line?
# If so then check the line to see if we should mail it out.
if ($check_line == 1)
{
($date, $rest) = split(/,/,$_,2);
($day_name, $mnth_nme, $mnth_day, $rest) = split(/[ \t\n]+/,$date,4);
if (($mnth_nme eq $month_name) && (($mday - $mnth_day) <= 3))
{
$send_mail = 1;
}
else
{
$send_mail = 0;
}
}
# If so then print the line.
print if $send_mail;
}
sub init
{
local(@month);
local($sec,$min,$hour,$mon,$year,$wday,$yday,$isdst);
@month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',
'Nov','Dec');
$send_mail = 0;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
while ($mon-- > -1)
{
$month_name = shift(@month);
}
}
--
Jeff Stuart Internet: kentba!jstuart@mcs.kent.edu
Kent State University UUCP : ...!uunet!telxon!teleng!kentba!jstuart
Kent, Ohio 44449 (216) 672-3282
#include std.disclaimer