Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up pollen type text and fix bug seen with perl 5.20.2 #521

Merged
merged 1 commit into from
Jul 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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