use Benchmark; $reps=500000; $x.=("a".."z")[rand 26] for (1..256); Benchmark::cmpthese($reps, { 'sub256' => '$_=$x;s/e//g;', 'trn256' => '$_=$x;tr/e//d;', }); print "-"x40,"\n"; $x=""; $x.=("a".."z")[rand 26] for (1..1024); Benchmark::cmpthese($reps, { 'sub1024' => '$_=$x;s/e//g;', 'trn1024' => '$_=$x;tr/e//d;', }); print "-"x40,"\n"; $x=""; $x.=("a".."z")[rand 26] for (1..5120); Benchmark::cmpthese($reps, { 'sub5k' => '$_=$x;s/e//g;', 'trn5k' => '$_=$x;tr/e//d;', }); print "-"x40,"\n";