in reply to regex match in array
If one or more of these requirements do not fit your situation, then grep is a great alternative. By nature it processes the entire list even if a match was found on the first item - this allows you to determine how many times an item appears in the array. It is also relatively fast since it is a built-it function.
The third choice that I am presenting is actually my favorite. List::Util has first which will return true on first match or undef if the item is not found in the list. It allows you to pass a code reference as the argument which allows you to provide a regex, an exact match, or some custom Frankestein monster as the determining agent.Cheers - L~R
|
|---|