foreach my $test (@tests){ if($mask & $byte{$test}){ if (my $method = $t->can($test)) { $mask = $mask ^ $byte{$test} unless $t->$method(); } # else error handling! #if the test returned false we unset the bit } }