Yes, it's interesting and i've made a few more tests to find some optimization.
See below :

#!/usr/bin/perl use strict; use warnings; use Benchmark qw( cmpthese ); my $line = ('a' x 500) . 'b!' . ('a' x 20); cmpthese -10, { literal => sub {$line =~ /a.{1,10}b!/ }, literal_exp => sub {$line =~ /a(?>.{1,10})b!/ }, literal_look => sub {$line =~ /a(?>.{1,10})(?<=b!)/ }, class => sub {$line =~ / [a] .{1,10} [b] [!] /x}, class_exp => sub {$line =~ / a .{1,10} b [!] /x}, class_back => sub {$line =~ / a (?> .{1,10} ) b [!] /x}, class_back_look => sub {$line =~ / a (?> .{1,10} ) (?<=b[!]) /x +}, class_b => sub {$line =~ / a .{1,10} (?<=b[!]) /x +}, };
Rate class_b class class_back_look literal_look l +iteral class_back literal_exp class_exp class_b 2172/s -- -53% -72% -75% + -100% -100% -100% -100% class 4651/s 114% -- -40% -46% + -99% -99% -99% -99% class_back_look 7809/s 259% 68% -- -10% + -99% -99% -99% -99% literal_look 8658/s 299% 86% 11% -- + -99% -99% -99% -99% literal 640333/s 29376% 13666% 8100% 7296% + -- -9% -11% -13% class_back 704687/s 32338% 15050% 8924% 8039% + 10% -- -2% -4% literal_exp 722209/s 33145% 15426% 9149% 8242% + 13% 2% -- -2% class_exp 733546/s 33667% 15670% 9294% 8373% + 15% 4% 2% --

Thanks for your interest and your enlightment.


PooLpi

'Ebry haffa hoe hab im tik a bush'. Jamaican proverb

In reply to Re^7: Sort/Uniq Help by poolpi
in thread Sort/Uniq Help by learningperl01

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.