Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: *IN* Operator for the Perl wish list

by liz (Monsignor)
on Mar 30, 2007 at 16:31 UTC ( #607518=note: print w/replies, xml ) Need Help??

in reply to Re: *IN* Operator for the Perl wish list
in thread *IN* Operator for the Perl wish list

Rather than "grep", I would use List::Util's "first" function, because that short-circuits on the first match, rather than always trying all of the elements.


  • Comment on Re^2: *IN* Operator for the Perl wish list

Replies are listed 'Best First'.
Re^3: *IN* Operator for the Perl wish list
by ysth (Canon) on Mar 30, 2007 at 17:33 UTC
    I haven't benchmarked it, but I suspect first has significantly more overhead, so might only be of benefit for long lists. I'd be interested in seeing a benchmark.

    Update: yes, I mean even the XS version

      Not necessarily -- List::Util has XS versions of all its functions.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://607518]
[ambrus]: "could evacuate to open schoolyard and then call or go back to school" => wait what? like power cycling the school building by removing all the kids and then reentering them? how would that fix the problems?
[ambrus]: https://www.xkcd. com/723/ is relevant about earthquakes and phones

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2017-01-18 12:38 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.