in reply to Re^2: delete multiple string blocks
in thread delete multiple string blocks

Sure. Working from the inside out:

  1. 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)
  2. grep attempts the block of code against every element of the supplied array and returns those which evaluate to a true value.
  3. 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.