From f33da96df59373d896b8f99c7f22e70b47f29f61 Mon Sep 17 00:00:00 2001 From: JaredF Date: Sun, 5 Jul 2015 20:34:35 -0700 Subject: [PATCH] Clean up pollen type text and fix bug seen with perl 5.20.2 --- code/common/weather_pollen.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/common/weather_pollen.pl b/code/common/weather_pollen.pl index ac96ae54a..bb31bf749 100644 --- a/code/common/weather_pollen.pl +++ b/code/common/weather_pollen.pl @@ -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/\.//; }