Some benchmarks:
use Benchmark qw(:all); sub in2 { my $q = shift; return { map({ ($_ => 1); } @_) }->{$q}; } sub in1 { my $val = shift; $val eq $_ and return 1 for @_; return 0; } sub in3 { my $q = shift; grep({ $q eq $_ } @_); } use Set::Scalar; sub in4 { my $q = shift; Set::Scalar->new(@_)->has($q); } use List::Util qw(first); sub in5 { my $q = shift; first { $q eq $_ } @_; } sub in6 { my $q = shift; grep /^$q$/, @_; } my @list1 = ('a', 'b', 'c', 'd'); my @list2 = ('d', 'b', 'c', 'd'); print '1 ', in1(@list1), ' ', in1(@list2), "\n"; print '2 ', in2(@list1), ' ', in2(@list2), "\n"; print '3 ', in3(@list1), ' ', in3(@list2), "\n"; print '4 ', in4(@list1), ' ', in4(@list2), "\n"; print '5 ', in5(@list1), ' ', in5(@list2), "\n"; print '6 ', in6(@list1), ' ', in6(@list2), "\n"; cmpthese(-1,{ 'ambrus' => \&in1, 'osunderdog' => \&in4, 'rnahi' => \&in5, 'gam3' => \&in2, 'EvanCarroll' => \&in6, 'Aristotle' => \&in3}); __END__
                Rate osunderdog    rnahi     gam3   ambrus Aristotle EvanCarroll
osunderdog    3412/s         --     -89%     -98%     -99%      -99%        -99%
rnahi        30117/s       783%       --     -79%     -87%      -94%        -95%
gam3        143359/s      4101%     376%       --     -40%      -73%        -75%
ambrus      238312/s      6884%     691%      66%       --      -54%        -58%
Aristotle   521308/s     15177%    1631%     264%     119%        --         -8%
EvanCarroll 566538/s     16502%    1781%     295%     138%        9%          --
-- gam3
A picture is worth a thousand words, but takes 200K.

In reply to Re: Too much SQL not enough perl by gam3
in thread Too much SQL not enough perl by jcpunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.