]> dxcluster.org Git - dweather.git/commitdiff
fix day changing logic
authorDirk Koopman <djk@tobit.co.uk>
Sun, 28 Dec 2014 19:57:00 +0000 (19:57 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Sun, 28 Dec 2014 19:57:00 +0000 (19:57 +0000)
SMGLog.pm

index d52d9b3f57ec65e244a64d66cb15a4891fe585fe..e826a5301a964584854e080778ce507db24f4c3f 100644 (file)
--- 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