#!/usr/bin/perl use strict; use warnings; use Benchmark qw/:all :hireswallclock/; my $test_str='error'; my @test=map { my @chr=("\0", " "); local $_=$test_str; s/./$& ^ $chr[rand 2]/ge} 1..100; no warnings 'void'; cmpthese -30, { regex => sub { /^\Q$test_str\E$/i for @test }, lc => sub { $test_str eq lc for @test} }, 'all'; __END__