From b762dc20cbed7321de2e9d6bb99bdfca7f50bcf9 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 30 Nov 2024 18:49:24 +0000 Subject: [PATCH] fhem.pl: add smartmatch replacements (Forum #137776) git-svn-id: https://svn.fhem.de/fhem/trunk@29380 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 99a13b2c3..31055cefa 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -6488,4 +6488,16 @@ CheckRegexp($$) return undef; } +# smartmatch replacement #137776 +# use contains_($scalar, @array) instead of $scalar ~~ @array +sub contains_numeric($@) { + my ($scalar, @array) = @_; + return (grep { $_ == $scalar } @array > 0); +} + +sub contains_string($@) { + my ($scalar, @array) = @_; + return (grep { $_ eq $scalar } @array > 0); +} + 1;