in reply to Re: Problem wrapping prototyped function [SOLVED]
in thread Problem wrapping prototyped function [SOLVED]
The reason why people want to use any instead of grep is to break as soon as the condition is true.
Example: Test array for odd numbers:
DB<47> use List::MoreUtils qw/any/ DB<48> @x=1..10000;() DB<49> $i=0; $flag= any { $i++; $_ %2 } @x; ($i,$flag) => (1, 1) DB<50> $i=0; $flag= grep { $i++; $_ %2 } @x; ($i,$flag) => (10000, 5000)
Looks like you reimplemented grep, just slower.
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Problem wrapping prototyped function [SOLVED]
by Laurent_R (Canon) on Dec 18, 2013 at 19:58 UTC |