Hello, Monks,
I have a number of string values with which I want to compare my data being tested:
if($data =~ /val1|val2|val3/) { doSomething(); }
The number of values is quite big and the regular expression wouldn't be nice if I'd continue developing it that way. I'd liked to populate the regexp from an array dynamically. However, I can't think of an idea of how to make it nicely.
So the question is, how to improve such a code? This problem could be generalized as follows: how to check if the data is in a given set defined by array?
Thank you very much.
In reply to Dynamic regexp from array values by Heidegger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |