use Regex::PreSuf; my $bigregex = presuf( values %msgDefn ); my $start = time(); while( ){ print if /$bigregex/; } my $end = time(); print "Time taken was ", ($end - $start), " seconds";