@filenames = split /\s.*?(?:KEY|CERT)/, $garbled_output; #### /s whitespace .*? any character (.), unlimited length (*), as few as possible (?) (?: non-capturing group KEY literal | OR CERT literal ) end group