$x = 0 unless $x == 7; $x = 8 if $x == 7; # ... or maybe ternary operator? ... $x = $x == 7 ? 8 : 0;