Skip to content

Instantly share code, notes, and snippets.

@xaicron
Created July 5, 2011 14:57
Show Gist options
  • Save xaicron/1064997 to your computer and use it in GitHub Desktop.
Save xaicron/1064997 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Benchmark qw(cmpthese);
my $regexp = qr/test/;
my @data = qw(Test foo Baz 2tesT);
my @lc_data = map { lc $_ } @data;
cmpthese -1 => {
ignore => sub {
$_ =~ /$regexp/i for @data;
},
lc => sub {
lc($_) =~ /$regexp/ for @data;
},
non => sub {
$_ =~ /$regexp/ for @data;
},
lc_data => sub {
$_ =~ /$regexp/ for @lc_data;
}
}, 'all';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment