#!/usr/bin/perl -w use strict; use Benchmark 'cmpthese'; our $s = "HELLOWORLD" x 1024; cmpthese(1_000_000, { 'slash_i' => sub { $s =~ m/hello/i; $s =~ m/jello/i }, 'brackets' => sub { $s =~ m/[Hh][Ee][Ll][Ll][Oo]/; $s =~ m/[Jj][Ee][Ll][Ll][Oo]/; }, });