2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: add smartmatch replacements (Forum #137776)

git-svn-id: https://svn.fhem.de/fhem/trunk@29380 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2024-11-30 18:49:24 +00:00
parent 06e4a6e841
commit b762dc20cb

View File

@ -6488,4 +6488,16 @@ CheckRegexp($$)
return undef;
}
# smartmatch replacement #137776
# use contains_<type>($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;