]> www.fi.muni.cz Git - slotcarman.git/commitdiff
LogReader: handle EOF correctly
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sat, 7 May 2011 21:09:17 +0000 (23:09 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sat, 7 May 2011 21:42:03 +0000 (23:42 +0200)
SCX/LogReader.pm

index 78d2b50768c61a8414f8ea24a8c6eac4244772cf..26aaaaaa2c01d427cba57cd898d6793a1863eddf 100644 (file)
@@ -29,7 +29,10 @@ sub get_data {
        my ($line, $l_time, @data);
        do {
                $line = <$fh>;
-               return undef if !defined $line;
+               if (!defined $line) {
+                       print STDERR "End of the log file reached.\n";
+                       return ();
+               }
 
                chomp $line;
                $line =~ s/\A\s+//xms;
@@ -37,7 +40,10 @@ sub get_data {
                ($l_time, @data) = split(/\s+/, $line);
        } while ($l_time < $self->{begin_time});
 
-       return undef if $l_time > $self->{end_time};
+       if ($l_time > $self->{end_time}) {
+               print STDERR "Requested end time reached.\n";
+               return ();
+       }
 
        return ($l_time, map { hex $_ } @data);
 }