#!perl-w use Benchmark qw(:all); $toto = 'this+is+my+text'; $count =-5; $results = timethese($count, { 'Indexing' => sub { my($copy)=$toto; $index = index($copy, 'is');}, 'matching' => sub { my($copy)=$toto;$match if $copy =~/is/; }, }, 'none' ); cmpthese( $results ) ; __END__ Gave: Rate matching Indexing matching 552818/s -- -14% Indexing 641382/s 16% --