Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 11ed71cadd7957cc80324bce7f970ff282d081ca
      
https://github.com/Perl/perl5/commit/11ed71cadd7957cc80324bce7f970ff282d081ca
  Author: Lukas Mai <lukasmai....@gmail.com>
  Date:   2024-09-04 (Wed, 04 Sep 2024)

  Changed paths:
    M pod/perlretut.pod

  Log Message:
  -----------
  perlretut: fix sample code

- consistently use `%count` everywhere, not `%count2`
- add missing `lc()` to first example

Also, remove incorrect performance claims:

    use strict;
    use warnings;
    use Benchmark qw(cmpthese);

    my $string = "supercalifragilisticexpialidocious";
    cmpthese -5, {
        re_embed => sub {
            my %count;
            $string =~ /([aeiou])(?{ $count{lc $1}++; })(*FAIL)/i;
            my $result = '';
            $result .= sprintf "%3d '%s'\n", $count{$_}, $_ for (sort keys 
%count);
            $result
        },
        split => sub {
            my %count;
            $count{lc $_}++ for split(//, $string);
            my $result = '';
            $result .= sprintf "%3d '%s'\n", $count{$_}, $_ for ( qw{ a e i o u 
} );
            $result
        },
    };

shows that the version with embedded code blocks in the regex is
consistently slower, not faster:

                 Rate re_embed    split
    re_embed 113698/s       --     -37%
    split    181717/s      60%       --

Fixes #22263.



To unsubscribe from these emails, change your notification settings at 
https://github.com/Perl/perl5/settings/notifications

Reply via email to