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:
parent
06e4a6e841
commit
b762dc20cb
12
fhem/fhem.pl
12
fhem/fhem.pl
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user