From: Dirk Koopman Date: Sun, 28 Dec 2014 19:57:00 +0000 (+0000) Subject: fix day changing logic X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=97030cb0b3250d71c71d5099429abeae859eac81;p=dweather.git fix day changing logic --- diff --git a/SMGLog.pm b/SMGLog.pm index d52d9b3..e826a53 100644 --- a/SMGLog.pm +++ b/SMGLog.pm @@ -124,11 +124,11 @@ sub opennext sub write { my ($self, $dayno, $line) = @_; - if (!$self->{fh} || $self->{mode} ne "r" || $dayno != $self->{dayno}) { + if ((!$self->{fh} || $dayno != $self->{dayno}) && $self->{mode} ne "r") { $self->open($dayno, "a+") or confess "can't open $self->{fn} $!"; - } + } - return $self->{fh}->print("$line\n"); + return $self->{fh} ? $self->{fh}->print("$line\n") : undef; } # read a line from an opened file