From 7ef05e0c00fb97d16b9876f67ac2bfbffd00938d Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Thu, 29 Dec 2022 04:41:10 +0100 Subject: [PATCH] fix some regex formating --- controls_Weather.txt | 2 +- lib/FHEM/APIs/Weather/wundergroundAPI.pm | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/controls_Weather.txt b/controls_Weather.txt index 2691ecf..f343b82 100644 --- a/controls_Weather.txt +++ b/controls_Weather.txt @@ -1,4 +1,4 @@ UPD 2022-12-28_09:21:01 54815 FHEM/59_Weather.pm UPD 2022-12-28_09:20:44 49883 lib/FHEM/APIs/Weather/DarkSkyAPI.pm UPD 2022-12-28_09:20:52 32101 lib/FHEM/APIs/Weather/OpenWeatherMapAPI.pm -UPD 2022-12-28_09:20:32 35424 lib/FHEM/APIs/Weather/wundergroundAPI.pm +UPD 2022-12-29_04:40:05 35600 lib/FHEM/APIs/Weather/wundergroundAPI.pm diff --git a/lib/FHEM/APIs/Weather/wundergroundAPI.pm b/lib/FHEM/APIs/Weather/wundergroundAPI.pm index 9a9396f..ce68fe2 100644 --- a/lib/FHEM/APIs/Weather/wundergroundAPI.pm +++ b/lib/FHEM/APIs/Weather/wundergroundAPI.pm @@ -7,6 +7,7 @@ use FHEM::Meta; use POSIX; use HttpUtils; use experimental qw /switch/; +use Encode; my $META = {}; my $ret = FHEM::Meta::getMetadata( __FILE__, $META ); @@ -75,8 +76,10 @@ eval { my $missingModul = ''; -# use Data::Dumper; # for Debug only -## API URL +## no critic (Conditional "use" statement. Use "require" to conditionally include a module (Modules::ProhibitConditionalUseStatements)) +eval { use Encode qw /encode_utf8/; 1 } + or $missingModul .= 'Encode '; + eval { use Readonly; 1 } or $missingModul .= 'Readonly '; # apt install libreadonly-perl ## use critic @@ -370,7 +373,7 @@ sub _ProcessingRetrieveData { and defined($response) and $response ) { - if ( $response =~ m/^\{.*\}$/ ) { + if ( $response =~ m/^\{.*\}$/x ) { my $data = eval { decode_json( encode_utf8($response) ) }; if ($@) { _ErrorHandling( $self, @@ -486,13 +489,13 @@ sub _ProcessingRetrieveData { while ( $i < $days ) { $data->{moonriseTimeLocal}[$i] =~ - s/^(....-..-..T..:..).*/$1/; + s/^(....-..-..T..:..).*/$1/x; $data->{moonsetTimeLocal}[$i] =~ - s/^(....-..-..T..:..).*/$1/; + s/^(....-..-..T..:..).*/$1/x; $data->{sunriseTimeLocal}[$i] =~ - s/^(....-..-..T..:..).*/$1/; + s/^(....-..-..T..:..).*/$1/x; $data->{sunsetTimeLocal}[$i] =~ - s/^(....-..-..T..:..).*/$1/; + s/^(....-..-..T..:..).*/$1/x; push( @{ $self->{cached}{forecast}{daily} },