Help for this page

Select Code to Download


  1. or download this
        'vanilla' => sub {
                if ($text =~ /gotcha/) {
                    $pre = $`;
    ...
                }
            },
        }
    
  2. or download this
        print "vanilla\n";
        print "prematch  :", $`, "\n";
        print "match     :", $&, "\n";
        print "postmatch :", $', "\n";
    
  3. or download this
    Benchmark: timing 500000 iterations of substr, unpack, vanilla...
    substr:  5 wallclock secs <snip> @ 106678.05/s
    unpack:  8 wallclock secs <snip> @ 54241.70/s
    vanilla: 0 wallclock secs <snip> @ 492125.98/s
    
  4. or download this
    my ($i, $j, $k);
    for ('a' .. 'z', 'A' .. 'Z') {
      $i++ if $text2 =~ /$_/;
    }
    $j++ if $text3 =~ /quux/;
    $k++ if $text4 =~ /H/;
    
  5. or download this
    substr: 25 wallclock secs ...
    unpack: 26 wallclock secs ...
    vanilla: 26 wallclock secs ...
    
  6. or download this
    use strict;
    use warnings;
    use Benchmark qw(timethese);
    ...
    sub substr_postmatch {
        substr( $_[0],  $+[0] )
    }