which gives you the efficiency of performing a single match,
A single match is not always more efficient. A bunch of simple matches can be more efficient than a single, more complicated, match. And that's because of the Perl optimizer. Here's an example:
#!/usr/bin/perl use strict; use warnings; use Regexp::Assemble; use Perl6::Slurp; use Benchmark qw /cmpthese/; use Test::More tests => 1; our @data = slurp '/usr/share/dict/words'; our(@a, @b); cmpthese(-10, { regex => '@a = grep {/qu/ || /x/} @data', ra => 'my $re = Regexp::Assemble->new->add("qu")->add("x")->re; @b = grep {/$re/} @data', }); is_deeply(\@a, \@b); __END__ 1..1 Rate ra regex ra 4.71/s -- -65% regex 13.5/s 186% -- ok 1

In reply to Re^2: Regex and question of design by Anonymous Monk
in thread Regex and question of design by amaguk

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.