grep doesn't close, so the order of the elements doesn't matter.
While List :: MoreUtils first performs a short circuit, the entire list must be pushed on the stack before it is called.
It will be better:
for (@bar) { if ($foo == $_) { some code; last; } }
Updated . I initially iterated over the indices, since it uses O (1) memory, but also for (@bar) (as opposed to for (LIST) in general), since ysth reminded me.
ikegami
source share