use strict; use Benchmark qw(cmpthese); cmpthese (-10, { a => 's/\s*#.*//', b => '$_ = $` if /#/', c => 'my ($line) = split/#/', d => '$_ = substr($_, 0, $-[0]) if /#/', e => 'if ((my $p = index($_, "#")) > -1) { substr($_, $p, -1, "") }' });