in reply to regex match in array

rsiedl,
In Perl, we have the motto "There Is More Than One Way To Do It". Variations of this particular problem come so often, that there are lots of solutions. Converting to a hash is a great solution if you consider a few points:

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