Documentation for control flow with orwith without

Documentation for control flow with orwith without, assembled from the following types:

control flow if

From if

(if) control flow with orwith without

The with statement is like if but tests for definedness rather than truth. In addition, it topicalizes on the condition, much like given:

with "abc".index("a"{ .say }      # prints 0 

Instead of elsif, orwith may be used to chain definedness tests:

# The below code says "Found a at 0" 
my $s = "abc";
with   $s.index("a"{ say "Found a at $_" }
orwith $s.index("b"{ say "Found b at $_" }
orwith $s.index("c"{ say "Found c at $_" }
else                 { say "Didn't find a, b or c" }

You may intermix if-based and with-based clauses.

# This says "Yes" 
if 0 { say "No" } orwith Nil { say "No" } orwith 0 { say "Yes" };

As with unless, you may use without to check for undefinedness, but you may not add an else clause:

my $answer = Any;
without $answer { warn "Got: $_" }

There are also with and without statement modifiers:

my $answer = (AnyTrue).roll;
say 42 with $answer;
warn "undefined answer" without $answer;