changeset 382:5573c1681da9

fetch_weather: Trim split input data lines in FMI XML.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 07 Feb 2016 18:49:11 +0200
parents 846a0a95ad5a
children 1ba1191da15d
files fetch_weather.pl
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_weather.pl	Sun Feb 07 18:17:21 2016 +0200
+++ b/fetch_weather.pl	Sun Feb 07 18:49:11 2016 +0200
@@ -63,6 +63,15 @@
 }
 
 
+sub str_trim($)
+{
+  my $tmp = $_[0];
+  $tmp =~ s/^\s*//;
+  $tmp =~ s/\s*$//;
+  return $tmp;
+}
+
+
 sub parse_timestamp($$)
 {
   my ($str, $offs) = @_;
@@ -429,8 +438,8 @@
       {
         for (my $nline = 0; $nline < scalar(@position_lines); $nline++)
         {
-          my $dline = $data_lines[$nline];
-          my $pline = $position_lines[$nline];
+          my $dline = str_trim($data_lines[$nline]);
+          my $pline = str_trim($position_lines[$nline]);
 
           my @fmatches = ($dline =~ /\s*([\+\-]?\d+\.\d*|NaN)\s*/ig);
           if (scalar(@fmatches) != scalar(@fmitems))