From 97030cb0b3250d71c71d5099429abeae859eac81 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Sun, 28 Dec 2014 19:57:00 +0000 Subject: [PATCH] fix day changing logic --- SMGLog.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.43.0