Sure. Working from the inside out:
- index looks for the substring within the string. Any result greater than -1 indicates it has been found. (If you know your substrings are always at the beginning of the string you can check for zero here)
- grep attempts the block of code against every element of the supplied array and returns those which evaluate to a true value.
- if tests all this for truth, ie. if the list returned by grep has elements.
Note that grep isn't the most efficient here because it will go on testing even after a match is found. For a short array/list it won't matter much. For a longer array/list you might want List::Util::any instead.
|