You are quite right. grep will search through the entire list on every iteration. first is the way to go but your looping through the indexes is more self explanatory.

In reply to Re^3: Array searching, grep, first by ChrisR
in thread Array searching, grep, first by jimbus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":