#!/usr/bin/perl # # $Id: it-vs-regex 2592 2003-12-21 00:33:01Z jmates $ # # The author disclaims all copyrights and releases this document into # the public domain. # # Comparison of split and various regex. use Benchmark qw:cmpthese:; $_ = "one two three four five six"; cmpthese(-5, { 'split' => '$f = (split /\s+/)[3]', 'evil-re' => '($f) = /^(?:\w+\s+){3}(\w+)/', 'thrig-re' => '($f) = /(\b\w+\b\W+){3}\b(\w+)/', 'b-re' => '($f) = /^.*?\s.*?\s.*?\s(\w+)/', });