grep {$_ == 0 and $found = 1 and last} @middle; #### { grep {$_ == 0 and $found = 1 and last} @middle; } #### Benchmark: timing 1000 iterations of foreach_middle, grep_middle, hash_middle... foreach_middle: 1 wallclock secs ( 0.80 usr + 0.00 sys = 0.80 CPU) @ 1250.00/s (n=1000) grep_middle: 3 wallclock secs ( 3.09 usr + 0.00 sys = 3.09 CPU) @ 323.62/s (n=1000) hash_middle: 30 wallclock secs (26.40 usr + 0.02 sys = 26.42 CPU) @ 37.85/s (n=1000)