#!/usr/bin/perl use warnings; use strict; use Benchmark; use constant SIZE => 1000; our @a1 = map { "a".$_ } (1..SIZE); our @a2 = map { "A".$_ } (1..SIZE); sub use_re { my $count = 0; foreach my $i (@a1) { foreach my $j (@a2) { if ($i =~ /^\Q$j\E$/i) { $count++; } } } die unless $count == SIZE; } sub use_lc { my $count = 0; foreach my $i (@a1) { foreach my $j (@a2) { if (lc $i eq lc $j) { $count++; } } } die unless $count == SIZE; } timethese(10, { RegExp => \&use_re, lc => \&use_lc, });