use Benchmark (':all'); my($foo, $bar); cmpthese((-1), {'ternary', sub { ((int(rand(2)) ? ($foo = 1) : $bar) = 1); } , 'if_else', sub { if (int(rand(2))) { ($foo = 1); } else { ($bar = 1); } } });