Hello,
I have a script that I want to print only if between 08:00 and 17:00. Would I match
every hour then print?? Any cleaner way to do this would be great. Thanks
my($sec,$min,$hour,$mday,$mon);
($sec,$min,$hour,$mday,$mon)=localtime;
$timestamp=sprintf("%3s %02d %02d:%02d:%02d",$Month[$mon],$mday,$hour,$min,$sec);
my $pidstring="pid(".$$."),";
while(<STDIN>){
$line = $_;
if($line=~/OK/){
open( OKLIST,">>/var/log/log.ok");
print OKLIST $timestamp,":",$pidstring,$line;
close(OKLIST);
}else{
if ( $hour =~ /^(08:|09:|10:|11:|12:|13:|14:|15:|16:|17:)/){
open( ERRLIST,">>/var/log/err.ok");
print ERRLIST $timestamp,":",$pidstring,$line;
close(ERRLIST);
chomp($line);
}
}
}
exit;
rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>