Of course, another approach would be to common-case all lines before matching...

Adding this other approach to your benchmark test…

C:\>type 634253.pl #!perl use strict; use warnings; use Benchmark qw( cmpthese ); use English qw( -no_match_vars ); local $OUTPUT_RECORD_SEPARATOR = "\n"; print 'Perl version: ', $PERL_VERSION; my $s = 'Aid bears out ' x 10_000_000; print 'Length of string: ', length $s; cmpthese(-1, { 'lc' => sub { lc($s) =~ m{ [aeiou][aeiou] }xmsg }, '[Aa][Aa]' => sub { $s =~ m{ [AaEeIiOoUu][AaEeIiOoUu] }xmsg }, '[Aa]{2}' => sub { $s =~ m{ [AaEeIiOoUu]{2} }xmsg }, '/i' => sub { $s =~ m{ (?i) [aeiou]{2} }xmsg }, }); exit 0; C:\>perl 634253.pl Perl version: v5.16.2 Length of string: 140000000 Rate lc [Aa][Aa] /i [Aa]{2} lc 5.20/s -- -100% -100% -100% [Aa][Aa] 2915419/s 56073120% -- -23% -25% /i 3764119/s 72396452% 29% -- -3% [Aa]{2} 3877869/s 74584244% 33% 3% -- C:\>perl 634253.pl Perl version: v5.16.2 Length of string: 140000000 Rate lc [Aa]{2} /i [Aa][Aa] lc 4.94/s -- -100% -100% -100% [Aa]{2} 2814401/s 57019656% -- -8% -25% /i 3044909/s 61689750% 8% -- -19% [Aa][Aa] 3762832/s 76234868% 34% 24% -- C:\>

In reply to Re^5: Vowel search by Jim
in thread Vowel search by Noob@Perl

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.