#! perl -slw use strict; use Benchmark qw[ cmpthese ]; use List::Util qw[ first ]; our @array = 1 .. 100_000; cmpthese( -1, { func_10th => q[ my $first = first{ length > 3 } @array; # print "F:$first"; ], iter_10th => q[ my $first; for ( @array ) { next unless length > 3; $first = $_; last; } # print "I:$first"; ], func_last => q[ my $first = first{ length > 5 } @array; # print "F:$first"; ], iter_last => q[ my $first; for ( @array ) { next unless length > 5; $first = $_; last; } # print "I:$first"; ], }); __END__ P:\test>381208 Rate func_last iter_last func_10th iter_10th func_last 22.0/s -- -16% -98% -99% iter_last 26.1/s 18% -- -98% -99% func_10th 1196/s 5336% 4488% -- -56% iter_10th 2706/s 12201% 10282% 126% --