#!/usr/bin/perl -w use Benchmark; my $txt = 'find this regex'; my $str = 'regex?'; my $rgx = qr/$str/i; timethese ( 1000000, { match => sub{ $txt =~ m/$str/i }, qreg => sub{ $txt =~ $rgx }, }, );