JanneVee,
The tutorial covers a bit of this, but I will go into more depth here.
List::Util's
first is designed to generic and portable. It is prototyped to $@ where the first argument is the code reference that will be applied to the remaining items in the list. It starts at the beginning and returns as soon as the code ref evaluates to true. This does not need to be an exact match as you could use a regex in block for instance. It does have a couple of issues with regards to efficiency.
- It does not provide ability to pass by reference so the @_ stack of aliases has to be generated. This can be costly on large lists
- The code reference has to be dereferenced for each item in the list until a match is found.
Now you can roll your own to be more efficient but that defeats the purpose of having portable re-useable code. Additionally, shaving a second or two off of run time is seldom worth the programmer time required to achieve it.