#!/usr/local/bin/perl -w use strict; use Benchmark; my $foo = 0; # $foo will be toggled between true and false my $x; timethese(-10, { mod => sub { $x = 1 if $foo ^= 1 }, block => sub { if ($foo ^= 1) { $x = 1 } }, and => sub { $foo ^= 1 and $x = 1 }, } ); __END__ Benchmark: running and, block, mod, each for at least 10 CPU seconds... and: 233020.67/s block: 230307.69/s mod: 234463.20/s Benchmark: running and, block, mod, each for at least 10 CPU seconds... and: 237002.40/s block: 236647.46/s mod: 226841.12/s