#!/usr/bin/perl use strict; use warnings; use Benchmark qw/cmpthese :hireswallclock/; my @a = do { my @chr=(grep /\w/, map chr, 1..255); map { local $_ = join '', map $chr[rand @chr], 1..1000; tr/_/ / if .5 { Regex => sub () { grep !/_/, @a }, Index => sub () { grep index($_, '_') < 0, @a } }; __END__