Skip to content

Commit

Permalink
Merge pull request #521 from JaredF/weather_pollen_update
Browse files Browse the repository at this point in the history
Clean up pollen type text and fix bug seen with perl 5.20.2.  Closes #520
  • Loading branch information
JaredF committed Jul 7, 2015
2 parents b0a625b + f33da96 commit 3eb25e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code/common/weather_pollen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@
&parse_pollen_forecast if (($Reload) && (-e $pollen_file));

sub parse_pollen_forecast {
my @pollen_data = file_read($pollen_file) || warn "Unable to open pollen data file.";
my $pollen_data = file_read($pollen_file) || warn "Unable to open pollen data file.";
# The JSON file that is retuned by the service is malformed; these substitutions clean it up so that the perl JSON module can parse it.
for (@pollen_data) {
for ($pollen_data) {
s/\"\{/\{/;
s/\\//g;
s/\}\"/\}/;
}
my $json = decode_json(@pollen_data) || warn "Error parsing pollen info from file.";
my $json = decode_json($pollen_data) || warn "Error parsing pollen info from file.";
$main::Weather{TodayPollenCount} = $json->{pollenForecast}{forecast}[0];
$main::Weather{TomorrowPollenCount} = $json->{pollenForecast}{forecast}[1];
$main::Weather{TodayPollenType} = $json->{pollenForecast}{pp};
# Format the pollen type text to remove any leading spaces or trailing periods.
$main::Weather{TodayPollenType} =~ s/^\s//;
$main::Weather{TodayPollenType} =~ s/\.//;
}

Expand Down

0 comments on commit 3eb25e2

Please sign in to comment.