Karyn Williams schreef: > #!/usr/bin/perl -w
Make that: #!/usr/bin/perl use strict; use warnings; > my $a = 1; > while ($a < 7) { Alternative: foreach my $a (1..7) { > if ($ext_mon <= 9) { > $ext = $ext_year . '0' . $ext_mon; > } > else { > $ext = $ext_year . $ext_mon; > } Alternative: $ext = sprintf "%s%02d", $ext_year, $ext_mon; > $current = $current - 86400; Alternative: $current -= 86400; > open MAILLOG, "/var/adm/maillog" or die "couldn't open > maillog : $!\n"; > if ($count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > /var/adm/maillog.\n"; next ; > } else { > close MAILLOG; > > open MAILLOG, "/export/home/archives/maillog.$flist[1]" or die > "couldn't open maillog.$flist[1] : $!\n"; > if ($count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > maillog.$flist[1].\n"; next ; > } else { > close MAILLOG; > > open MAILLOG, "/export/home/archives/maillog.$flist[2]" or die > "couldn't open maillog.$flist[2] : $!\n"; > if ( $count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > maillog.$flist[2].\n"; next ; > } else { > close MAILLOG; > > open MAILLOG, "/export/home/archives/maillog.$flist[3]" or die > "couldn't open maillog.$flist[3] : $!\n"; > if ( $count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > maillog.$flist[3].\n"; next ; > } else { > close MAILLOG; > > open MAILLOG, "/export/home/archives/maillog.$flist[4]" or die > "couldn't open maillog.$flist[4] : $!\n"; > if ( $count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > maillog.$flist[4].\n"; next ; > } else { > close MAILLOG; > > open MAILLOG, "/export/home/archives/maillog.$flist[5]" or die > "couldn't open maillog.$flist[5] : $!\n"; > if ( $count = grep /user=$k/o, <MAILLOG> ) { > print "$k checked mail $count times in > maillog.$flist[5].\n"; next ; > } else { > close MAILLOG; print "$k has not checked their mail in the > last 6 months.\n"; There is a lot of repetition in there. Make sure that '/var/adm/maillog' is in $flist[0] and that the others have full paths too. foreach my $f (@flist) { open my $log, $f or die "error with '$f': $!\n"; if ($count = grep /\buser=$k\b/, <$log> ) { print "$k checked mail $count times in $f.\n"; last; } } And if you were not interested in the count: foreach my $f (@flist) { LOGCHECK: open my $log, $f or die "error with '$f': $!\n"; while (<$log>) { m/\buser=$k\b/ and print("$k checked mail (in $f)\n") and last LOGCHECK; } } (untested) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/