#! perl -slw use strict; use Benchmark qw[ cmpthese ]; cmpthese -1, { one_eval => q[ my $t = 1; eval qq[ sub count { \$_[0] =~ tr[$t][$t] } ]; my $c = 0; $c += count( $_ ) for 1 .. 1e6; print $c; ], many_evals => q[ my $t = 1; my $c = 0; $c += eval qq[ \$_ =~ tr[$t][$t] ] for 1 .. 1e6; print $c; ], }; __END__ C:\test>junk30 600001 600001 (warning: too few iterations for a reliable count) 600001 Subroutine count redefined at (eval 2000016) line 1. 600001 Subroutine count redefined at (eval 2000017) line 1. 600001 Subroutine count redefined at (eval 2000020) line 1. 600001 (warning: too few iterations for a reliable count) s/iter many_evals one_eval many_evals 27.3 -- -98% one_eval 0.416 6451% --