# HG changeset patch # User Matti Hamalainen # Date 1449865161 -7200 # Node ID a52a983c0c14c0fbfe9d6b8161938502bfebb5df # Parent 19b363586b4019e65d8150a338d7680b1886f61f Cosmetics. diff -r 19b363586b40 -r a52a983c0c14 fetch_weather.pl --- a/fetch_weather.pl Fri Dec 11 22:16:18 2015 +0200 +++ b/fetch_weather.pl Fri Dec 11 22:19:21 2015 +0200 @@ -221,27 +221,37 @@ { $line++; chomp; - if (/(^\s*#|^\s*$)/) { + if (/(^\s*#|^\s*$)/) + { # Ignore comments and empty lines - } elsif (/^\s*\"?([a-zA-Z0-9_]+)\"?\s*=>?\s*(\d+),?\s*$/) { + } + elsif (/^\s*\"?([a-zA-Z0-9_]+)\"?\s*=>?\s*(\d+),?\s*$/) { my $key = lc($1); my $value = $2; if (defined($settings{$key})) { $settings{$key} = $value; - } else { + } + else + { mlog("[$filename:$line] Unknown setting '$key' = $value\n"); $errors = 1; } - } elsif (/^\s*\"?([a-zA-Z0-9_]+)\"?\s*=>?\s*\"(.*?)\",?\s*$/) { + } + elsif (/^\s*\"?([a-zA-Z0-9_]+)\"?\s*=>?\s*\"(.*?)\",?\s*$/) { my $key = lc($1); my $value = $2; - if (defined($settings{$key})) { + if (defined($settings{$key})) + { $settings{$key} = $value; - } else { + } + else + { mlog("[$filename:$line] Unknown setting '$key' = '$value'\n"); $errors = 1; } - } else { + } + else + { mlog("[$filename:$line] Syntax error: $_\n"); $errors = 1; } @@ -448,12 +458,16 @@ } } print STDERR $nrecords." records from FMI.\n" if (opt_get_int("debug") > 0); - } else { + } + else + { # defined print STDERR "Invalid XML received:\n"; print STDERR $res->decoded_content."\n\n"; } - } else { + } + else + { print STDERR "Error fetching FMI XML: ".$res->status_line."\n"; } } @@ -462,7 +476,8 @@ ### ### Output ### -if (opt_chk_valid("outfile", 1)) { +if (opt_chk_valid("outfile", 1)) +{ open(STDOUT, '>', opt_get("outfile")) or die("Could not open output file '".opt_get("outfile")."'.\n"); }